I’m trying to use SWR for fetching data but I’m getting this error. Not sure why this is happening, though it works fine with use effect hook.
This is the json data where it is fetching from –
{
"dashboards": {
"posts": 5,
"likes": 5,
"followers": 5,
"followings": 5
}
}
>Solution :
Use optional chaining see if that works:
<p>
{data?.posts}
</p>
<p>
{data?.likes}
</p>

