mirror of
https://github.com/donl/plivo-node.git
synced 2026-06-30 06:12:08 -06:00
Fixed review comments
This commit is contained in:
parent
53d5340dc4
commit
25946cc682
1 changed files with 7 additions and 7 deletions
|
|
@ -17,11 +17,11 @@ export function Axios(config) {
|
|||
const max_time = options.retryTime;
|
||||
let counter = 0;
|
||||
axios.interceptors.response.use(null, (error) => {
|
||||
const config = error.config
|
||||
const config = error.config;
|
||||
if (counter < max_time && error.response.status >= 500) {
|
||||
counter++
|
||||
counter++;
|
||||
return new Promise((resolve) => {
|
||||
resolve(axios(config))
|
||||
resolve(axios(config));
|
||||
})
|
||||
}
|
||||
return Promise.reject(error)
|
||||
|
|
@ -30,17 +30,17 @@ export function Axios(config) {
|
|||
|
||||
return (method, action, params) => {
|
||||
if (typeof (params) != 'undefined' && typeof (params.file) != 'undefined') {
|
||||
var files = []
|
||||
let files = [];
|
||||
if (Array.isArray(params.file)) {
|
||||
for (let index = 0; index < params.file.length; index++) {
|
||||
files[index] = require('fs').createReadStream(params.file[index])
|
||||
files[index] = require('fs').createReadStream(params.file[index]);
|
||||
}
|
||||
} else {
|
||||
files[0] = require('fs').createReadStream(params.file);
|
||||
}
|
||||
params.file = files;
|
||||
}
|
||||
var options = {
|
||||
let options = {
|
||||
url: config.url + '/' + action,
|
||||
method: method,
|
||||
data: params || '',
|
||||
|
|
@ -85,7 +85,7 @@ export function Axios(config) {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (isVoiceReq) {
|
||||
retryWrapper(axios, {retryTime: 2})
|
||||
retryWrapper(axios, {retryTime: 2});
|
||||
let retryAttempt;
|
||||
for (retryAttempt = 0; retryAttempt < 3; retryAttempt++) {
|
||||
options.url = apiVoiceUris[retryAttempt] + config.authId + '/' + action;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue