The Question : 646 people think this question is useful I’m trying to POST a JSON object using fetch. From what I can understand, I need to attach a stringified object to the body of the request, e.g.: When using jsfiddle’s json echo I’d expect to see the object I’ve sent ({a: 1, b: 2})
The Question : 655 people think this question is useful I’m trying to fetch some data from the REST API of HP Alm. It works pretty well with a small curl script – I get my data. Now doing that with JavaScript, fetch and ES6 (more or less) seems to be a bigger issue. I
问题内容: I am using Fetch API from react-native and I am using typescript. My code looks like this: let responseLogin = await fetch('http://url_example', { method: 'POST', headers: {'Content-Type':'application/json'}, body: requestBody }); But I get the following error where the header is: Argument of type '{ method: string; headers: { 'Content-Type': string; }; body: string; }'