weexteam / article

This repos is a third party collection, and is not developed nor maintained by Apache Weex.
1.22k stars 141 forks source link

Stream 浏览器Post 返回Data:null #146

Closed wqjGitHub closed 7 years ago

wqjGitHub commented 7 years ago
 stream.fetch({
    method: 'POST',
    url: POST_URL,
    type:'json',
    body: JSON.stringify({ data: bodyString })
  }, function(ret) {
      console.info("post", ret);
    if(!ret.ok){
      me.postResult = "request failed";
    }else{
      console.log('get:'+JSON.stringify(ret));
      me.postResult = JSON.stringify(ret.data);
    }
  },function(response){
    console.log('get in progress:'+response.length);
    me.postResult = "bytes received:"+response.length;
  });

服务器响应:{"status":200,"ok":true,"statusText":"OK","data":null,"headers":{"Content-Type":"application/json;charset=GBK"}}

其中data为null,服务器无法取到body内容,如果用get方式正常。 而jquery: $.ajax({ url : app.config.remote_addr, timeout : app.config.debug ? 40000 : 20000, dataType : 'json', data : { 'data' : JSON.stringify(json) }, type : 'POST', )};完全正常。