diff --git a/src/hooks/useAxios.ts b/src/hooks/useAxios.ts index c7bb626..792da85 100644 --- a/src/hooks/useAxios.ts +++ b/src/hooks/useAxios.ts @@ -16,9 +16,16 @@ const useAxios = () => { (config) => { const state = store.getState(); const token = state.token.token; + const shopId = state.shop_id?.shop_id; + if (token) { config.headers.Authorization = `Bearer ${token}`; } + + if (shopId) { + config.headers["Shop-ID"] = shopId; + } + return config; }, (error) => { @@ -32,8 +39,8 @@ const useAxios = () => { }, (error) => { if (error.response && error.response.status === 401) { - store.dispatch(setToken('')); - navigate('/login'); + store.dispatch(setToken("")); + navigate("/login"); } return Promise.reject(error); }