useSession returns undefined | token

#319 · closed · 0 comments

View on GitHub ↗

chris-muiru

lets say am using JWT credentials....i need to get the token from the useSession hook. ```js export const useAxiosPrivate = () => { const { data, status } = useSession() console.log(data) const axiosInstance = axios.create({ baseURL: `${SERVER_LOCALHOST}/api/v1`, headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${data?.user.accessToken}` } }) return axiosInstance } ``` i feel like because it will always return null | token,some requests will be sent with Bearer undefined....it there a way to avoid this???

Comments