-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom axios api override example has a typo #320
Labels
documentation
Improvements or additions to documentation
Comments
I just looked how I did this on a project try {
const result = await axios.request({
method: method as Method,
url: newPath,
headers: {
...headers,
...extraHeaders,
},
data: body,
});
return {
status: result.status,
body: result.data,
// @ts-expect-error toJSON is not typed
headers: new Headers(result.headers.toJSON()),
};
} catch (e: Error | AxiosError | unknown) {
if (isAxiosError(e)) {
const error = e as AxiosError;
const response = error.response as AxiosResponse;
return {
status: response.status,
body: response.data,
// @ts-expect-error toJSON is not typed
headers: new Headers(response?.headers?.toJSON() || ''),
};
}
throw e;
}
```
looks like we needed to use `new Headers(response?.headers?.toJSON() || '')` which isn't great. |
also interested by a cleaner fix here 👀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there, many thanks for this wonderful library! I'm trying to use axios for the interceptors and the example code provided has an issue with the
headers
property.In the try block return object
headers
property uses nonexistentresponse.headers
variable. Changing it toresult.headers
makes the whole block incompatible withapi
signature because axios headers are incompatible with the ones from theApiFetcherArgs
type.The text was updated successfully, but these errors were encountered: