我在下一个js中遇到这个错误
TypeError:无法在 eval 处读取未定义的属性(读取“标头”)(webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js :254:61)
代码片段示例:
newUser
.save()
.then(() =>
NextResponse.json({ msg: "Successfuly created new User: " + newUser ,status:200})
)
.catch((err: string) =>{
NextResponse.json({ error: "Error on '/api/register': " + err ,status:400})
}
);
Run Code Online (Sandbox Code Playgroud)
尝试了多种方法,例如导入NextApiRequest和NextApiResponse使用它。它没有状态和 JSON 属性,基本上它给出了类型错误属性不存在于NextApiResponse. 所以我NextResponse直接使用还是出现这个错误。