Next.js Discord

Discord Forum

Question about Error.js boundry (NEXTJS 13)

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Avatar
Cape lionOP
Hello guys.
I am trying to fetch my medium articles into my new app.

I have the following request in my component.
I am trying to create the error.js component.

To test, i changed the url to a faulty one like so:
/meddddddium.com/feed/@laramo

//Articles.tsx which is imported in Page.tsx
  const mediumData: MediumType = await axios
    .get(
      "https://api.rss2json.com/v1/api.json?rss_url=https://meddddddium.com/feed/@laramo"
    )
    .then((res) => {
      if (res.data) {
        return res.data;
      }
      throw new Error("Failed to fetch data");
    });

the error boundary shows after a while, but the API keeps fetching in a loop (view image)

is there a way to stop the API fetch after one error?
Image

0 Replies