I am trying to use SWR in Next.js for the first time. I am using Axios to make http calls. The Axios make calls to protected API routes and I handled that using interceptor.
Here is one of the places where I used the SWR but I am getting undefined
when I console.log(data)
from SWR
;
const getProfile = async()=>{
try {
const res = await axiosPrivate.get<axiosGetCompanyProfile>(`/getcompany`, {withCredentials: true, headers: {Authorization: `${state?.in_memory}`}});
console.log(res.data, 'mmmmnn')
return res.data;
} catch (error) {
return error
}
}
const { data, error, isLoading } = useSWR(`${getcompany`, getProfile)
What Am I doing wrongly?