Next.js Discord

Discord Forum

Next.JS ISR: What exactly happens if you make multiple API requests?

Answered
Swyftey posted this in #help-forum
Open in Discord
Avatar
I am still leaning Next.JS and am curious to know how ISR (Incremental Static Regeneration) works in a page if you make multiple requests? My current idea (see example below) was to hopefully cache the session data, and have it revalidate periodically, but not the data from the second fetch.

This is an example of what I am talking about:

const sessionData = await fetch("DOMAIN/auth/session", { next: { revalidate: 20 }); // The user's data needs to be retrieved via browser's session cookie before using the second API call. (If there is a better way of doing this, please feel free to share).

const otherData = await fetch("other-API-endpoint");

return ();
Answered by Swyftey
Okay. It looks like the "revalidate" option only applies to the request it is used on.
View full answer

1 Reply

Avatar
Okay. It looks like the "revalidate" option only applies to the request it is used on.
Answer