Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我想通过POST请求发送一个大型json对象_Javascript_Json_Fetch Api - Fatal编程技术网

Javascript 我想通过POST请求发送一个大型json对象

Javascript 我想通过POST请求发送一个大型json对象,javascript,json,fetch-api,Javascript,Json,Fetch Api,我使用fetch api向基于NodeJS/Express/MongoDB的api发送post请求,但不知何故,只有一些字段被发布到MongoDB集合。其余部分略去。当我在控制台中使用console.log打印整个js对象时,我得到一个带有。。。最后,当鼠标悬停在上方时,显示“下面的值是刚刚计算的”。看起来请求正在分块发送对象。我想把整个东西都寄出去。如何发送整个对象 前端: document.getElementById('contact-submit').onclick = async (e

我使用fetch api向基于NodeJS/Express/MongoDB的api发送post请求,但不知何故,只有一些字段被发布到MongoDB集合。其余部分略去。当我在控制台中使用console.log打印整个js对象时,我得到一个带有。。。最后,当鼠标悬停在上方时,显示“下面的值是刚刚计算的”。看起来请求正在分块发送对象。我想把整个东西都寄出去。如何发送整个对象

前端:

document.getElementById('contact-submit').onclick = async (e) => {
        e.preventDefault();

      console.log(postData('http://localhost:4001/people',{
            

                "name":document.getElementById('name').value.toString(),
                "age": document.getElementById('age').value ,
                "sex":document.getElementById('sex').value,
                "address":document.getElementById('address').value,
                "class": document.getElementById('class').value,
                "degree": Number(document.getElementById('degree').value),
                "grade":document.getElementById('grade').value,
                "notes":Date(document.getElementById('notes').value),
                "resume":Number(document.getElementById('resume').value),
                "skills":criteria,
                "rounds":rounds,
                
            
          }));
    }



    async function postData(url = '', data ={}){


        console.log(data);

        const response = await fetch(url, {

            

            method: 'POST',
            mode: 'cors',
            cache: 'no-cache',
            credentials: 'same-origin',
            headers:{
                'Content-Type': 'application/json',

            },
            redirect: 'follow',
            referrerPolicy: 'no-referrer',
            body: JSON.stringify(data)
        });
        return response.json();
    }
该对象来自一个表单,并且只有它的一部分被发布到api中。
另外,当通过postman操作时,API自身工作良好并发布完整的对象。

您已经发送了整个对象。“当我在控制台中使用console.log打印整个js对象时,我得到了一个结尾带有…的部分对象,当鼠标悬停在上面时,它显示“下面的值刚刚被计算过”。”这纯粹是控制台的事情。它与
fetch
发送的内容无关。是否尝试单击省略号
console.log
当对象较大时,不显示整个对象,但允许您展开字段及其内容的完整列表。尝试在“body:JSON.stringify(data)”行放置断点,查看是否完全接收到数据。是的,单击省略号显示整个对象,但只有一个对象块被发送到数据库集合。