The POST request server cannot get the parameters. It is found that Stream.fetch uses the method of directly turning the body into a string and passing it to the server. Our server requires an Ajax request (&key=value) like Jquery. The parameter intercepted by Charles is the key value in the request, but the keyValue style is obtained in jquery. In which file should I modify the method of submitting the body?
stream.fetch({
method: 'POST', url: POST_URL, type:'json',
// headers: {'Content-Type': 'application/json; charset=utf-8',},
body: JSON.stringify({ data: bodyString})//or you can just use JSON Object {username:'weex'} }, function(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; });
Add "Content-Type": 'application/x-www-form-urlencoded; to the request header
stream.fetch({