Next.js Discord

Discord Forum

'use server' fail to fetch data from API.

Unanswered
Spectacled bear posted this in #help-forum
Open in Discord
Spectacled bearOP
If I configure my page.tsx (Under app folder) with 'use client', and do a fetch, it could make API call to my springboot backend, but 'use server' fails without any error. However according to official doc, 'use client' is not recommended with async calls.
Why 'use server' fails to fetch data?
Sorry if it's a beginner quesiton but I didn't find reference in the official doc.

4 Replies

Do you see errors on the terminal?
Spectacled bearOP
No, if I do 'use server' simply nothing shows up
in the client component, you can import the server action and call it in some event handler to fetch the data