error: API resolved without sending a response for /XXXX/XXXX, this may result in stalled requests.

I am trying to use Next.js' useSWR for data fetching, but I have been receiving an undefined response. Upon checking the console, I encountered the following error:

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

Below is how I am fetching the data using useSWR

const fetcher = (url) => axios(url).then(r => r.data);

const { data, error, isLoading } = useSWR(url, fetcher, {
        fallbackData: article,
        // revalidateOnFocus: false,
    });

 

message profile
Admin
2023-05-30

From your code, I recommend adding handlers for data loading and validation using useSWR. It provides a way to do that. Here's an example:

 const { data, error, isLoading } = useSWR(url, fetcher, {
        fallbackData: article,
        // revalidateOnFocus: false,
    });
   

    if (error) return <>{error}</>;
    if (isLoading) return <><h1>Loading</h1></>;

Regarding the cause of the error, it usually occurs when you don't return any response from that specific endpoint. Check the "/XXXX/XXXX/ and ensure that its returning a response when there is a request.

Add Message

Click on the button below to add a new message to this thread

Tags

#Javascript #next js

Thread detail

Satus: Open
Messages: 1Started: 2023-05-30
loading..

DEVMAESTERS

Newsletter

Services

Frontend Development |Backend Development |Full Website Development |Bootstrap Website upgrades | Website Debbugging | Website Hosting & deployment

Contact

Interested in hiring me or collaborating with me on a project, click on any of the links below to get my social media handle

Or contact me via Tel: (+234)-806-225-7480 | Email: abubakarzakari1703@gmail.com

Copywright@devmaesters.com
Privacy Policy

By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.