4
Eae guys, I have a little problem to give a Retry in a POST using Next case exceeds Timeout. I’m trying to implement this(https://github.com/softonic/axios-retry) library next to Axios, but it doesn’t work. Let’s go to the code:
const axios = require('axios')
const convert = require('xml-js')
const axiosRetry = require('axios-retry');
const CLIENT = axios.create();
CLIENT.defaults.timeout = 1000
axiosRetry(CLIENT, {
retryCondition: (error) => {
return axiosRetry.isNetworkOrIdempotentRequestError(error) || error.code === 'ECONNABORTED';
}
});
class Consult {
constructor(username, password) {
this.username = username
this.password = password
}
async getResponse() {
const config = {
headers: {
'Content-Type': 'text/xml'
}
};
const xml = 'string_conection'
return await CLIENT.post('url', xml, config)
.then(response => {
const result = convert.xml2json(response.data, {
compact: true,
spaces: 4
})
return result
})
.catch(error => {
console.log(error.code);
});
}
}
module.exports = Consult
Who can help me :)
Hmm, good. It turns out that yesterday I also created my own function. I don’t know if I can post it here as an answer to help people...
– Develop_SP
@Develop_sp can yes, it is only important that you accept some answer as chosen so that the question stays in the normal flow, even if it is your own
– Sorack