Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve) => {
axios.request({
url,
// `method` ๆฏๅๅปบ่ฏทๆฑๆถไฝฟ็จ็ๆนๆณ
method: 'get', // ้ป่ฎคๆฏ get
// `onDownloadProgress` ๅ
่ฎธไธบไธ่ฝฝๅค็่ฟๅบฆไบไปถ
onDownloadProgress(progressEvent) {
// ๅฏนๅ็่ฟๅบฆไบไปถ็ๅค็
console.log('--------------------ไธ่ฝฝๅพ็่ฟๅบฆ:')
// console.log(progressEvent)
},
}).then(async (result) => {
if (result.status === 200) {
// eslint-disable-next-line no-param-reassign
result = result.data.data
} else {
return
// Handle qs
if (options.queryParameters) {
reqOptions.params = options.queryParameters;
reqOptions.paramsSerializer = QueryString.stringify;
}
// Handle body
if (options.body) {
reqOptions.data = options.body;
}
reqOptions = _.merge({}, reqOptions, extraRequestOptions);
let response;
let result;
try {
response = await axios.request(reqOptions);
result = response.data;
} catch (e) {
const maybeErrorData = idx(e, _ => _.response.data.errors.length);
if (maybeErrorData) {
result = e.response.data;
} else {
throw e;
}
}
if (result.errors && result.errors.length) {
let responseError = result.errors[0];
let error = new ApiV2Error(responseError.message, responseError.code);
error.serverStack = responseError.stack;
error.details = responseError.details;
throw error;
async requestInternal(
method: string,
url: string,
data: any,
retry = false,
retryNum = 0
): Promise> {
if (!retry) {
this.executeBefores();
}
const config: AxiosRequestConfig = this.buildAxiosConfig(method, url, data);
let response: AxiosResponse | undefined = undefined;
let ret: Response | undefined = undefined;
try {
response = await axios.request(config);
} catch (e) {
ret = this.handleException(e);
} finally {
removeCancelToken(config.cancelToken);
}
if (!ret) {
ret = await this.transformAndValidateResponse(
response!,
method,
url,
data,
retry,
retryNum
);
}
if (!retry) {
});
if (!authHeaderValue || authHeaderValue === "undefined") {
return;
}
customHeaders[uiOptions.authHeaderName] = authHeaderValue;
const config: AxiosRequestConfig = {
method: uiOptions.method,
url: uiOptions.url,
headers: customHeaders,
};
try {
const response = await axios.request(config);
const items: IKeyValuePair[] = response.data.map((item) => {
return {
key: interpolate(uiOptions.keySelector, { item }),
value: interpolate(uiOptions.valueSelector, { item }),
};
});
this.setState({
items,
});
} catch (e) {
return;
}
}
}
getHero(heroId) {
if (heroId == null) {
throw new Error("heroId must not be null!");
}
return axios.request({
method: 'GET',
url: `/heroes/${heroId}`,
baseURL: `${this.baseUrl}:${this.port}`,
headers: {
'Accept': 'application/json; charset=utf-8'
}
}, adapter).then((response) => {
const hero = response.data;
return new Promise((resolve, reject) => {
try {
this._validateIncomingHero(hero);
resolve(hero);
} catch (error) {
reject(error);
}
});
async socketEnvShouldBeUpdated () {
debug('socketEnvShouldBeUpdated')
try {
const resp = await axios.request({
url: `https://${session.getHost()}/v2/instances/${session.project.instance}/environments/${this.name}/`,
method: 'GET',
timeout: 50000,
headers: {
'X-Api-Key': session.settings.account.getAuthKey()
}
})
if (resp.data.metadata.checksum === this.getSocketNodeModulesChecksum()) {
debug('socketEnvShouldBeUpdated', 'env is up to date')
return false
}
return 'PATCH'
} catch (err) {
return 'POST'
}
export default ({account, workspace, authToken}) => {
return vtexToken
? Promise.resolve(vtexToken)
: http.request(
{
url: `http://router.aws-us-east-1.vtex.io/${account}/${workspace}/tokens/legacy`,
method: 'GET',
headers: {Authorization: `bearer ${authToken}`},
})
.then(({data}) => vtexToken = data)
}
static uploadFileToGoogleDrive(access_token, setMessage, fileName, data, salt = new ArrayBuffer(), iv = new ArrayBuffer()) {
setMessage("Starting upload to Google Drive\u2122. Do not close this window.", true);
return axios.request({
method: "POST",
url: `https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable`,
headers: {
"Authorization": `Bearer ${access_token}`,
"X-Upload-Content-Length": data.byteLength + salt.byteLength + iv.byteLength
},
data: { name: fileName, description: "File uploaded using Syncrypto (https://github.com/theapurvap/syncrypto)." }
}).then(response => axios.request({
method: "POST",
url: response.headers.location,
headers: {
"Authorization": `Bearer ${access_token}`,
"Content-Type": "multipart/form-data"
},
data: new Blob([data, salt, iv])
})).then(() => setMessage("File uploaded to Google Drive\u2122!", true)).catch(error => {
onSubmit={(values, { setSubmitting, setStatus }) => {
axios
.request({
url:
'https://api.formik.com/submit/undefinedfm/subscribe',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: {
...values,
},
})
.then(
() => {
setSubmitting(false);
setStatus('Success');
},