admin管理员组文章数量:1401469
I am trying to use a const from a context in my server side, inside /api
. But when I use this, my backend console returns:
TypeError: r is not a function
and
SyntaxError: Unexpected end of JSON input
in the request that, without the context, works perfectly.
I also checked the variable before using it and it is returning the string it should. How to solve this?
'use client'
import { calendarInsertContext } from './calendarInsertContext'
export async function GET(req) {
const { sdr } = useContext(calendarInsertContext)
console.log('sdr backend: ', sdr)
I am trying to use a const from a context in my server side, inside /api
. But when I use this, my backend console returns:
TypeError: r is not a function
and
SyntaxError: Unexpected end of JSON input
in the request that, without the context, works perfectly.
I also checked the variable before using it and it is returning the string it should. How to solve this?
'use client'
import { calendarInsertContext } from './calendarInsertContext'
export async function GET(req) {
const { sdr } = useContext(calendarInsertContext)
console.log('sdr backend: ', sdr)
Share
Improve this question
edited Apr 4, 2024 at 9:46
0xKevin
1,0571 gold badge10 silver badges35 bronze badges
asked Feb 2, 2024 at 23:33
Maria EduardaMaria Eduarda
831 silver badge6 bronze badges
1
- please provide the code where you have created context so that it will be more clear in debugging! – Abhishek Commented Feb 3, 2024 at 11:46
2 Answers
Reset to default 3I have got the same error, apparently i had used 'use client' in my route.ts file which was not required.
it got resolved. it seems that vs-code will not throw any error indicator in file whether we use 'use client' in a file or not.
If you're using 'next-auth' latest(beta) version it's happen, so downgrade 'next-auth' with stable version it would be resolved.
For more info - Follow this issue
本文标签: javascriptTypeError r is not a functionnextjsStack Overflow
版权声明:本文标题:javascript - TypeError: r is not a function - next.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744287446a2598948.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论