-
Hello, I'm currently working on a project where we need to ensure that every API request sent via Axios includes a Bearer token in the Authorization header. I understand that using Axios interceptors could be a solution for this. What I want to achieve: What I've tried: OpenAPI.interceptors.request.use(async (request) => {
const accessToken = ...;
if (request.headers) {
request.headers.Authorization = `Bearer ${accessToken}`;
}
return request;
}); My question: Thank you for your assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, please see #505 (reply in thread) and https://blog.logrocket.com/using-axios-set-request-headers/#:~:text=We%20can%20also%20use%20Axios,it%20is%20delivered%20to%20callbacks. |
Beta Was this translation helpful? Give feedback.
Hey, please see #505 (reply in thread) and https://blog.logrocket.com/using-axios-set-request-headers/#:~:text=We%20can%20also%20use%20Axios,it%20is%20delivered%20to%20callbacks.