OpenAPIClientAxios Interceptor to Set a header in React

Viewed 10

I am using OpenAPIClientAxios to call apis. What I need is when there is a request going out, I would like to add a header to the request.

I tried something like

import axios from "axios";
export function jwtInterceptor() {
axios.interceptors.request.use(request => {
    if (request.headers) {
        request.headers['test'] = 'test1234';
    }
    return request;
});}

However, it's never been called. I suspect it has something to do with OpenAPIClientAxios but not sure how to fix it. Any recommendation please?

0 Answers
Related