isomorphic-fetch 不要 post json body

isomorophic-fetch don't post json body

我的 React 应用程序中有这段代码,但它没有 post json 正文! 已经尝试了所有解决方案,甚至这里的 https://github.com/matthew-andrews/isomorphic-fetch/issues/34 也不起作用,我可以用 jquery 做 post,但我需要使用 fetch,知道吗?

fetch('/main/newuser',{
            method:'post',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
            },
            body:JSON.stringify({username:'test',password:'test'})
        }).then((response)=>{
            if(response.status >= 200 && response.status < 300){
                return response;
            }else{
                var error = new Error(response.statusText);
                error.response = response;
                throw error;
            }
        }).then((response)=>{
            return response.json();
        }).then((data)=>{
            /* Process data */
        }).catch((error)=>{
            /* Catch Error */
        });

在尝试了所有可能的方法后(按照建议编辑代码,检查浏览器是否更新并正常工作,检查服务器代码,库将使用 GET 方法工作,但 POST 仍然无法工作)我切换回来了致我们的旧爱 JQuery !