I have implemented CloudFlare turnstile so that when a certain API is called a 403 response is returned with an additional response header of cf-mitigated: challenge
. I’m using axios to catch and print the error, this is my code
type IAxiosResponseErrorData = unknown
type IAxiosResponseErrorBody = unknown
const onResponseReject = (
error: AxiosError<IAxiosResponseErrorData, IAxiosResponseErrorBody>
) => {
console.log("error", error)
// Do something if the error response has a certain header...
return Promise.reject(error);
};
instance.interceptors.response.use(onResponseSuccess, onResponseReject)
export default instance
When I try to print error.response
it logs undefined
. Weird thing is that the network tab shows the header I’m looking for
What am I missing?