[ad_1]
I’m trying to find the Axios equivalent to this jQuery ajax
$.ajax({
type: "GET",
url: urls[index],
cache: false,
dataType: "xml",
success: function (xml) {
Language.loadXml(xml);
Language.translateDocument(attrsToTranslate);
Language.languageFile = urls[index];
callback(true);
},
error: function (jqXHR: any, textStatus: string, errorThrown: string) {
app.log("Can't find language file :" + urls[index]);
Language.load(urls, index + 1, attrsToTranslate, callback);
}
});
This is the conversion I’ve done and please let me know whether this is the correct way
axios({
method: "get",
url: urls[index],
data:"xml",
headers:{
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': '0',
}
}).then(function (xml) {
Language.loadXml(xml);
Language.translateDocument(attrsToTranslate);
Language.languageFile = urls[index];
callback(true);
}).catch(function (error) {
Language.load(urls, index + 1, attrsToTranslate, callback);
});
[ad_2]