axios#AxiosInstance TypeScript Examples
The following examples show how to use
axios#AxiosInstance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: api.ts From selling-partner-api-sdk with MIT License | 6 votes |
FbaInboundApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = FbaInboundApiAxiosParamCreator(configuration)
return {
/**
* This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item\'s eligibility. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
* @param {string} asin The ASIN of the item for which you want an eligibility preview.
* @param {'INBOUND' | 'COMMINGLING'} program The program that you want to check eligibility against.
* @param {Array<string>} [marketplaceIds] The identifier for the marketplace in which you want to determine eligibility. Required only when program=INBOUND.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getItemEligibilityPreview(asin: string, program: 'INBOUND' | 'COMMINGLING', marketplaceIds?: Array<string>, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetItemEligibilityPreviewResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getItemEligibilityPreview(asin, program, marketplaceIds, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
}
Example #2
Source File: default-http-client.ts From rubic-sdk with GNU General Public License v3.0 | 6 votes |
private static addCacheDisablingInterceptor(axios: AxiosInstance): void {
axios.interceptors.request.use(
request => {
request.params = { ...request.params, timestamp: Date.now() };
return request;
},
error => Promise.reject(error)
);
}
Example #3
Source File: AxiosFactory.ts From node-experience with MIT License | 6 votes |
static getAxiosInstance(isPrivate = true): AxiosInstance
{
let config = { baseURL, timeout, headers: headersPrivate };
if (!isPrivate)
{
// @ts-ignore
config = { baseURL, timeout, headers: headersPublic };
}
return axios.create(config);
}
Example #4
Source File: testing.d.ts From openapi-cop with MIT License | 6 votes |
/**
* For each OpenAPI file in a given directory, it boots a proxy and a mock
* server and runs the provided test requests. It then executes the callback
* function that contains the test code.
*/
export declare function testRequestForEachFile({ testTitle, dir, testRequests, client, callback, defaultForbidAdditionalProperties, silent, }: {
testTitle: string;
dir: string;
testRequests: TestRequests;
client: {
proxy: AxiosInstance;
target: AxiosInstance;
};
callback: (proxyRes: AxiosResponse, targetRes: AxiosResponse, fileName: string, requestObject: TestRequestConfig) => void;
defaultForbidAdditionalProperties?: boolean;
silent?: boolean;
}): void;
Example #5
Source File: api.ts From selling-partner-api-sdk with MIT License | 6 votes |
VendorPaymentsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = VendorPaymentsApiFp(configuration)
return {
/**
* Submit new invoices to Amazon. **Usage Plans:** | Plan type | Rate (requests per second) | Burst | | ---- | ---- | ---- | |Default| 10 | 10 | |Selling partner specific| Variable | Variable | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
* @param {SubmitInvoicesRequest} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
submitInvoices(body: SubmitInvoicesRequest, options?: any): AxiosPromise<SubmitInvoicesResponse> {
return localVarFp.submitInvoices(body, options).then((request) => request(axios, basePath));
},
};
}
Example #6
Source File: agent.ts From F95API with MIT License | 6 votes |
/**
* Create a custom Axios agent already configurated.
*/
export default function createAxiosAgent(): AxiosInstance {
// Create the agent with the custom configuration
let agent: AxiosInstance = axios.create(commonConfig);
// Add support for cookies with tough-cookies
agent = addCookieJarSupport(agent);
// Add support to bypass DDoS guard
addDDoSSupport(agent);
// Enable Axios to retry a request in case of errors
axiosRetry(agent, {
retryDelay: axiosRetry.exponentialDelay, // Use exponential back-off retry delay
shouldResetTimeout: true // Timer resets after every retry
});
return agent;
}
Example #7
Source File: api.ts From selling-partner-api-sdk with MIT License | 6 votes |
VendorTransactionApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = VendorTransactionApiAxiosParamCreator(configuration)
return {
/**
* Returns the status of the transaction indicated by the specified transactionId. **Usage Plans:** | Plan type | Rate (requests per second) | Burst | | ---- | ---- | ---- | |Default| 10 | 10 | |Selling partner specific| Variable | Variable | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
* @param {string} transactionId Previously returned in the response to the POST request of a specific transaction.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getTransactionStatus(transactionId: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetTransactionResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getTransactionStatus(transactionId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
}
Example #8
Source File: axiosInterceptor.ts From twitch-live-extension with BSD 3-Clause "New" or "Revised" License | 6 votes |
axiosInterceptor = (axios: AxiosInstance): AxiosInstance => {
axios.interceptors.request.use(
async (config) => {
const token = await getToken();
if (token) {
config.headers['Authorization'] = `Bearer ${token}`;
}
return config;
},
(error) => Promise.reject(error),
);
//Add a response interceptor
axios.interceptors.response.use(
(response) => {
return response;
},
async (error) => {
const originalRequest = error.config;
originalRequest._retryCount = ++originalRequest._retryCount || 1;
if (originalRequest._retryCount < 3) {
const forceAuthenticationPopup: boolean = [401, 403].includes(
error?.response?.status,
);
const newToken = await getRefreshToken(forceAuthenticationPopup);
axios.defaults.headers.common['Authorization'] = `Bearer ${newToken}`;
return axios(originalRequest);
}
return Promise.reject(error);
},
);
return axios;
}
Example #9
Source File: api.ts From selling-partner-api-sdk with MIT License | 6 votes |
VendorShippingLabelsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = VendorShippingLabelsApiFp(configuration)
return {
/**
* Returns a shipping label for the purchaseOrderNumber that you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {string} purchaseOrderNumber The purchase order number for which you want to return the shipping label. It should be the same purchaseOrderNumber as received in the order.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getShippingLabel(purchaseOrderNumber: string, options?: any): AxiosPromise<ShippingLabel> {
return localVarFp.getShippingLabel(purchaseOrderNumber, options).then((request) => request(axios, basePath));
},
/**
* Returns a list of shipping labels created during the time frame that you specify. You define that time frame using the createdAfter and createdBefore parameters. You must use both of these parameters. The date range to search must not be more than 7 days. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {string} createdAfter Shipping labels that became available after this date and time will be included in the result. Must be in ISO-8601 date/time format.
* @param {string} createdBefore Shipping labels that became available before this date and time will be included in the result. Must be in ISO-8601 date/time format.
* @param {string} [shipFromPartyId] The vendor warehouseId for order fulfillment. If not specified, the result will contain orders for all warehouses.
* @param {number} [limit] The limit to the number of records returned.
* @param {'ASC' | 'DESC'} [sortOrder] Sort ASC or DESC by order creation date.
* @param {string} [nextToken] Used for pagination when there are more ship labels than the specified result size limit. The token value is returned in the previous API call.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getShippingLabels(createdAfter: string, createdBefore: string, shipFromPartyId?: string, limit?: number, sortOrder?: 'ASC' | 'DESC', nextToken?: string, options?: any): AxiosPromise<ShippingLabelList> {
return localVarFp.getShippingLabels(createdAfter, createdBefore, shipFromPartyId, limit, sortOrder, nextToken, options).then((request) => request(axios, basePath));
},
/**
* Creates a shipping label for a purchase order and returns a transactionId for reference. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
* @param {SubmitShippingLabelsRequest} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
submitShippingLabelRequest(body: SubmitShippingLabelsRequest, options?: any): AxiosPromise<TransactionReference> {
return localVarFp.submitShippingLabelRequest(body, options).then((request) => request(axios, basePath));
},
};
}
Example #10
Source File: tdapiinterface.ts From tda-api-client with GNU General Public License v3.0 | 6 votes |
instance: AxiosInstance = axios.create({
baseURL: "https://api.tdameritrade.com",
headers: {
"Accept": "*/*",
"Accept-Language": "en-US",
"DNT": 1,
"Host": "api.tdameritrade.com",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
},
})
Example #11
Source File: common.ts From selling-partner-api-sdk with MIT License | 5 votes |
createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
return axios.request(axiosRequestArgs);
};
}