I have tried many of the stack overflow solution but I am unable to solve this problem
My code is below
helper/axios.js
import axios from "axios";
const instance = axios.create({
baseURL: process.env.REACT_APP_BACKEND_URI,
timeout: 1000,
headers: {},
});
export default instance;
App.js
import axios from "./helper/axios";
const { user } = useAppSelector((state) => state);
axios.interceptors.request.use((config: any) => {
if (user.isLoggedIn) {
config.headers.authorization = user.accessToken;
config.headers["x-refresh"] = user.refreshToken;
console.log(config);
}
return config;
});
[Image of console] [1]: https://i.sstatic.net/fWAIb.png