I need help please.
So, in my react app, I have a function that’s making a request to an external API
, The API server
requires a stable IP
making request to it, instead axios is sending the device’s IP
, I tried setting the default IP
with x-fawarded-for
in the header, but It could not work. Can someone help me with how I can set the default requesting IP
in axios?
const getBillerCategories = () => {
const authorization = {
"Accept": 'application/json',
"Content-Type": "application/json",
"x-api-key": BAXI_API_KEY // this is the API Key
"x-forwarded-for": "xxx.xx.x.xxx" // the required IP
}
return new Promise((resolve, reject) => {
//console.log(authorization, 'n', ' chekced ', 'n');
axios.get(BAXI_BASE_URL+'/billers/category/all', {headers: authorization}).then((response) => {
resolve({status: true, data: response.data});
}).catch((error) => {
console.log(error.response.data, 'response data', BAXI_API_KEY);
if(error.response){
resolve({status: false, error: error.response.data.hasOwnProperty('message') ? error.response.data.message: error.response.data.toSting()});
}else{
resolve({status: false, error: error.message});
}
});
});
}
Thank you in advance.