小编Pra*_*yan的帖子

如何修复错误(TypeError:无法分配给对象“#<QueryCursor>”的只读属性“map”)

我通过 Mongoose 将数据发送到 MongoDB。现在,在为其获取 API 路由期间,会抛出错误。

代码

const addChoice = async (e) => {
    try {
        e.preventDefault();
        const res = await fetch("/api/sendChoice", {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                choiceSeq: choice,
                checkSubmit: true,
            }),
        });
        console.log(res);
        router.push("/home");
    } catch (error) {
        console.log(error);
    }
};
Run Code Online (Sandbox Code Playgroud)

错误发生在const res = await fetch("/api/sendChoice" ,{

在终端服务器中出现错误

错误 - TypeError:无法分配给对象“#<QueryCursor>”的只读属性“map”

在检查元素中,错误如下
这

我找不到与解决此问题相关的任何内容,我什至不明白该错误意味着什么,试图自己解决它。

我的项目中的其他一些相关代码:

api/sendChoice

import { getSession } from "next-auth/client";
import dbConnect from "../../helpers/dbConnect";
import Choice from "../../models/Choice";

export default async function …
Run Code Online (Sandbox Code Playgroud)

typeerror fetch mongoose mongodb next.js

10
推荐指数
3
解决办法
8166
查看次数

标签 统计

fetch ×1

mongodb ×1

mongoose ×1

next.js ×1

typeerror ×1