#How to toggle proxy url in package.json based on the ixp flag? React App...#
I would like - the switching of proxy url based on different value of some-variable inside the service class:
I have two proxy servers: - "https://tst.api1.com" and "https://tst.api2.com"
inside React component i have getSex() function that returns either male or female, if male - i would like to invoke api1 else api2;
package.json:
{
"proxy": {
"/abc": {
"target": "https://tst.api1.com" // i need this to be toggeled based on getSex() value
}
}
}
React Component:
export async function getAllUsers() {
const response = await fetch('/abc/users');
return await response.json();
}