kitloong / nextjs-dashboard

A Next.JS boilerplate with the famous Open Source Boostrap Admin Template, CoreUI.
https://nextjs-dashboard-olive.vercel.app
MIT License
563 stars 215 forks source link

404 on api call #26

Closed tongene closed 3 months ago

tongene commented 3 months ago

This is a screenshot from the index page of the Pokemons client component. On the page which is a server component, the API call works correclty. Should the API in the Index component have this behaviour? It keeps returning a 404. In my case, when I try to fetch from supabase using the same functions, I actually get a 401 unauthorised error. Is there a reason an error pops up on the same component when calling an API?

image

kitloong commented 3 months ago

Hi @tongene , thank you for reporting.

I have the wrong URL on the useSWR that's why you will keep receiving 404 error.

If you get 401 most probably your API required your authentication.

I have implemented useSWR so that I could fetch the fresh data client side.

If you remove the useSWR and with some updates you could convert to a server component, feel free to update base on your need.

tongene commented 3 months ago

Ok. Thanks. You are right, the 401 went away after a few attempts to fix it.