-1

I'm tryin to fetch data from my api but fast refresh causing error when I try to know why I found that next js has a bug req.params work only for once because fast refresh feature in next js do you know a solution or any other way get id from url other than req.params in express js Thank you for your time

express js code)

the code in next js

  • Before asking question, it may be beneficial to take the [tour](https://stackoverflow.com/tour) and read the various pages in the [help center](https://stackoverflow.com/help), particularly [How to Ask](https://stackoverflow.com/help/how-to-ask) or [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors). – devpolo Mar 14 '23 at 09:38
  • Can you [edit](https://stackoverflow.com/posts/75731340/edit) your question and paste your code as code blocks instead of images. What is the error you're getting? Could you add that to the question as well? – RubenSmn Mar 14 '23 at 09:39

1 Answers1

0

A common issue with the router is that the query param is undefined on the first render. You can use router.isReady or check that the id is not undefined before sending the api call

Disco
  • 1,304
  • 1
  • 6
  • 12