typescript axios post向后台传递数组报错,求解!谢谢!

async saveMenu(data: Model[]) {

    let reqConfig: AxiosRequestConfig = {
        method: "post",
        url: globalConfig.prefixPath + "/webapp/api/menu/save",
        data: { data: data},
        headers: {
            "Content-Type": "application/json"
        }
    };
    let dr = await Axios.request(reqConfig);
  
    return dr
}

clipboard.png

阅读 2k
1 个回答

又是循环引用造成的,用下面的代码就解决了
let cache: any = []

    let str = JSON.stringify(pd, function (key, value) {
        if (typeof value === 'object' && value !== null) {
            if (cache.indexOf(value) !== -1) {
                // Circular reference found, discard key
                return;
            }
            // Store value in our collection
            cache.push(value);
        }
        return value;
    });
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进