Skip to content

Instantly share code, notes, and snippets.

@kcak11
Last active March 20, 2025 12:26
Show Gist options
  • Save kcak11/fc6a0377ea605378da445e204db54f87 to your computer and use it in GitHub Desktop.
Save kcak11/fc6a0377ea605378da445e204db54f87 to your computer and use it in GitHub Desktop.
Axios Overwrite Script

Axios Overwrite Script

let axios = require("axios");
/** ~~~~~~~~~~~ **/
let tenant = "ashish";
let _axios = axios;
axios = function () {
if (arguments[0] && arguments[0].url) {
arguments[0].url = arguments[0].url.split("/default/").join("/" + tenant + "/");
}
return _axios.apply(null, arguments);
};
for (var key in _axios) {
axios[key] = _axios[key];
}
if (axios.request) {
let _axios_r = axios.request;
axios.request = function () {
if (arguments[0] && arguments[0].url) {
arguments[0].url = arguments[0].url.split("/default/").join("/" + tenant + "/");
}
return _axios_r.apply(axios, arguments);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment