beekai-oss / little-state-machine

📠 React custom hook for persist state management
https://lrz5wloklm.csb.app/
MIT License
1.47k stars 53 forks source link

Access the CreateStore Outside a React Component #143

Closed NarenderSiri closed 1 year ago

NarenderSiri commented 1 year ago

Store value I want to use here .. This is too important to me . Please give answer

export default function setupAxios(axios, store) { axios.interceptors.request.use( (config) => { const { auth: { tokens: { authorization_token } }, } = store.getState();

    if (authorization_token) {
        config.headers.Authorization = `Bearer ${authorization_token}`;
    }

    return config;
},

(err) => Promise.reject(err) ); }

bluebill1049 commented 1 year ago

if you are using session storage, you can just query the session storage data.