'ReactJS API call - Need redirect URL in response from request with 30X status without redirecting
I have an API which returns 30X response and redirects to a specific URL. But, I want to get redirect URL from response without redirection.
I am using this in ReactJs code. Please find samples I tried:
let optionData = {
method: "get",
headers: headerData,
maxRedirect: 0,
redirect: "manual"
};
fetch(url, optionData)
.then((response) => {
//I need redirect URL here
console.log(response);
console.log(response.headers);
})
Using this, I am getting response object as below:
{
"body": null,
"nodyUsed": false,
"headers": {},
"ok": false,
"redirected": false,
"status": 0,
"statusText": "",
"type": "opaqueredirect"
}
But, I am not getting redirect URL from this response.
I have also tried using axios, node-fetch, XMLHttpRequst.
Can you please help me to get this redirect url without redirection?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|