I have a url that redirects to a second url, and I want to be able to access the second redirected url. If I paste the url into my browser and open Chrome Dev Tools, I can see the redirected url in the Response Headers.
Image of redirect url in Chrome Dev Tools
I can also see the redirect url in Terminal with curl. Image of curl GET request/response
However, performing a regular GET request using Postman I am unable to access the response headers, and making a GET request in axios returns an error.
export const getTikTokRedirectLink = async () => {
try {
const finalUrl = 'https://www.tiktok.com/t/ZTRemVWYt/?k=1';
const response = await axios.get(`${finalUrl}`);
console.log(response);
return response.data;
} catch(error) {
const result: IAPIResponse = {
data: null,
hasError: true,
};
console.log('Error:' , error);
return result;
}
};
How can I get access to the redirect url https://www.tiktok.com/@shopmybazar/video/7094675643446807854?_t=8TYGqYqaUSA&_r=1 using the input url https://www.tiktok.com/t/ZTRemVWYt/?k=1?
Are you passing all the required request headers? You can check same in the image .