Last active
March 20, 2025 12:26
-
-
Save kcak11/fc6a0377ea605378da445e204db54f87 to your computer and use it in GitHub Desktop.
Axios Overwrite Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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