Next.js Discord

Discord Forum

Problem with API and fetching

Answered
Batimius posted this in #help-forum
Open in Discord
Hello there. I'll make this as short as possible. For some reason, when making a fetch request, it caches the result even though I have cache set to no-store. Relevant code will be posted below.
Answered by Batimius
Fixed it by moving the fetch call outside of the component class (and at the end, by simply getting rid of it completely and using functions to fetch the data manually)
View full answer

6 Replies

page.tsx
api/v2/compareInfo/route.ts
api/v2/createComparison/route.ts
lib/getComparison.ts
And the output (can clearly see that after the first request, it doesn't bother making another even though cache is set to no-store)
Fixed it by moving the fetch call outside of the component class (and at the end, by simply getting rid of it completely and using functions to fetch the data manually)
Answer