typeError: Cannot read properties of undefined (reading 'headers')
Unanswered
Cassin's Kingbird posted this in #help-forum
Cassin's KingbirdOP
0
I am trying to send data to API using fetch in NextJS with Nextjs route handlers but when data is receive in server/API route it say error.
I can get value from category.name but then it show the error message
I am trying to send data to API using fetch in NextJS with Nextjs route handlers but when data is receive in server/API route it say error.
I can get value from category.name but then it show the error message
5 Replies
your code looks correct 🤔 what version of next.js are you using?
you just need to change the return of the route handler to use
NextResponsereturn NextResponse.json({ body: newCategory })i reported this bug here https://github.com/vercel/next.js/issues/51130
they should've at least provided a clearer error message