Answer the question
In order to leave comments, you need to log in
How to set fetcher to default SWR library in my case?
I have an axios addon that adds headers and inserts token.
export const instance = (token: string | undefined) => {
return axios.create({
baseURL: 'http://localhost:8000',
headers: {
'Content-Type': 'application/json',
Authorization: `Token ${token}`
}
})
}
<SWRConfig
value={{
revalidateOnMount: true,
dedupingInterval: 1000,
fetcher: (url) => axios(url).then(r => r.data)
}}
>
export const instance = axios.create({
baseURL: 'http://localhost:8000',
headers: {
'Content-Type': 'application/json',
Authorization: `Token ${Cookie.get('token')}`
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question