I have to make same changes in my nextjs project because my enpoint API doesn't support many calls and I would like to make a refresh from the original data every 3 min.

I implemented API from nextjs: I create a pages/api/data and inside I make the call to my endpoint, and in my getInitialProps inside index call to data file.

The get works okey, but I have 2 problems:

1: I have and alert message that says:

API resolved without sending a response for /api/data, this may result in stalled requests.

2: It dosen 't reload data after 3 min..I supouse it is beacuse Cache-Control value...

This is my code:

Respuesta :

The API routes provided by Next.js give you a means to build your API. Each file in the pages/api subdirectory is mapped to /api/* and treated more like an API endpoint than a page.

The API routes provided by js provide a way to build your API. Each file in the pages/api subdirectory is mapped to /api/* and treated more like an API endpoint than a page. Because they are server-side only bundles, they don't raise the size of your client-side bundle. An API route won't work until you export a function as default (also known as a request handler). The following arguments are thus accepted by this function:

To build your whole API for new applications, use API Routes.

To know more about API click here:

https://brainly.com/question/27852304

#SPJ4