axios#AxiosPromise TypeScript Examples
The following examples show how to use
axios#AxiosPromise.
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: apiService.ts From Tiquet with MIT License | 6 votes |
get(path: string, params?: object): AxiosPromise {
const token = this.cookies.get('token');
const fullPath = [this.api, path].join('');
const data = {
params,
headers: {}
};
if (token) {
data['headers']['token'] = token;
}
return axios.get(fullPath, data);
}
Example #2
Source File: requests.ts From nova-editor with GNU General Public License v3.0 | 6 votes |
export function sendEventsBatch(events: Array<LogEvent>, user: string, app: string): AxiosPromise {
return axios({
method: "post",
url: `${baseUrl}/events/batch`,
data: {
user,
app,
events,
},
});
}
Example #3
Source File: api.ts From selling-partner-api-sdk with MIT License | 6 votes |
AuthorizationApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = AuthorizationApiAxiosParamCreator(configuration)
return {
/**
* With the getAuthorizationCode operation, you can request a Login With Amazon (LWA) authorization code that will allow you to call a Selling Partner API on behalf of a seller who has already authorized you to call Amazon Marketplace Web Service (Amazon MWS). You specify a developer ID, an MWS auth token, and a seller ID. Taken together, these represent the Amazon MWS authorization that the seller previously granted you. The operation returns an LWA authorization code that can be exchanged for a refresh token and access token representing authorization to call the Selling Partner API on the seller\'s behalf. By using this API, sellers who have already authorized you for Amazon MWS do not need to re-authorize you for the Selling Partner API. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
* @summary Returns the Login with Amazon (LWA) authorization code for an existing Amazon MWS authorization.
* @param {string} sellingPartnerId The seller ID of the seller for whom you are requesting Selling Partner API authorization. This must be the seller ID of the seller who authorized your application on the Marketplace Appstore.
* @param {string} developerId Your developer ID. This must be one of the developer ID values that you provided when you registered your application in Developer Central.
* @param {string} mwsAuthToken The MWS Auth Token that was generated when the seller authorized your application on the Marketplace Appstore.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getAuthorizationCode(sellingPartnerId: string, developerId: string, mwsAuthToken: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetAuthorizationCodeResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getAuthorizationCode(sellingPartnerId, developerId, mwsAuthToken, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
}
Example #4
Source File: check-video-streams.ts From aqualink-app with MIT License | 6 votes |
fetchVideoDetails = (
youTubeIds: string[],
apiKey: string,
): AxiosPromise<YouTubeApiResponse> => {
return axios({
url: 'https://www.googleapis.com/youtube/v3/videos',
method: 'get',
params: {
key: apiKey,
id: youTubeIds.join(),
part: 'status,liveStreamingDetails',
},
});
}
Example #5
Source File: lambda-helpers.ts From roamjs-com with MIT License | 6 votes |
wrapAxios = (
req: AxiosPromise<Record<string, unknown>>,
event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> =>
req
.then((r) => ({
statusCode: 200,
body: JSON.stringify(r.data),
headers: headers(event),
}))
.catch((e) => ({
statusCode: e.response?.status || 500,
body: e.response?.data ? JSON.stringify(e.response.data) : e.message,
headers: headers(event),
}))
Example #6
Source File: index.ts From keptn-azure-devops-extension with Apache License 2.0 | 6 votes |
function handleApiError(err: Error | AxiosError): AxiosPromise {
// If the error is an AxiosError, we can try to extract the error message from the
// response and display it in the pipeline or just use the Axios error message
if (axios.isAxiosError(err)) {
if (err.response) {
// Response is most likely a JSON encoded object
if (err.response.data instanceof Object) {
throw Error(err.response.data.message);
}
// If it's a string it could also be some payload that axios didn't understand
if (err.response.data instanceof String || typeof err.response.data === "string") {
throw Error(`Received error from Keptn:\n${err.response.data}`);
} else if (err.request) {
throw Error(`Did not receive a response from Keptn: ${err.message}`)
}
}
throw Error(err.message);
} else {
throw err;
}
}
Example #7
Source File: GptAPI.ts From prompts-ai with MIT License | 6 votes |
static generateCompletions(prompt: string | Array<string>, completionParams: CompletionParameters,
n: number = 1): AxiosPromise {
return axios({
method: "POST",
url: `https://api.openai.com/v1/engines/${completionParams.engine}/completions`,
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${completionParams.apiKey}`,
},
data: {
"prompt": prompt,
"n": n,
"max_tokens": completionParams.maxTokens,
"temperature": completionParams.temperature,
"stop": completionParams.stop,
"top_p": completionParams.topP,
"presence_penalty": completionParams.presencePenalty,
"frequency_penalty": completionParams.frequencyPenalty
}
});
}
Example #8
Source File: request.ts From github-profile-summary-cards with MIT License | 6 votes |
export default function request(header: any, data: any): AxiosPromise<any> {
return axios({
url: 'https://api.github.com/graphql',
method: 'post',
headers: header,
data: data,
raxConfig: {
retry: 10,
noResponseRetries: 3,
retryDelay: 1000,
backoffType: 'linear',
httpMethodsToRetry: ['POST'],
onRetryAttempt: err => {
const cfg = rax.getConfig(err);
core.warning(err);
core.warning(`Retry attempt #${cfg?.currentRetryAttempt}`);
}
}
});
}
Example #9
Source File: XAPI.ts From xapi with MIT License | 6 votes |
protected requestResource(params: {
resource: Resources;
queryParams?: RequestParams;
requestConfig?: AxiosRequestConfig | undefined;
requestOptions?: GetParamsBase;
}): AxiosPromise<any> {
const extendedQueryParams = Object.assign({}, params.queryParams);
if (params.requestOptions?.useCacheBuster) {
extendedQueryParams["cachebuster"] = new Date().getTime().toString();
}
const url = this.generateURL(params.resource, extendedQueryParams);
return this.requestURL(url, params.requestConfig);
}
Example #10
Source File: index.tsx From Tiquet with MIT License | 5 votes |
mapDispatchToProps = dispatch => ({
fetchPriorities: () => dispatch(fetchPriorities()),
fetchBoard: (boardId): AxiosPromise => dispatch(fetchBoard(boardId)),
resetState: () => dispatch(resetState()),
deleteList: (listId: number) => dispatch(deleteList(listId)),
sortList: (listId: number, taskId: number,index: number, destinationIndex: number) => dispatch(sortList(listId, taskId, index, destinationIndex)),
moveTask: (originListId, destinationListId, taskId, destinationIndex) => dispatch(moveTask(originListId, destinationListId, taskId, destinationIndex)),
})