title: How can I construct a POST request body in React Native not with a stringified json but a json?
body: <p>I working on replace some native-code with react native. The expected POST request (implemented in <code>AFNetworking</code>) in <code>Charles</code> should be like this:</p>
  
  <p><a href="https://i.stack.imgur.com/uLIo1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uLIo1.png" alt="AFNetworking POST"></a></p>
  
  <p>Code snippet:</p>
  
  <pre><code>NSError *err;
  NSData *paramData = [NSJSONSerialization dataWithJSONObject:parameters options:NSJSONWritingPrettyPrinted error:&amp;err];
  NSData *paramData = [NSJSONSerialization dataWithJSONObject:parameters options:NSJSONWritingPrettyPrinted error:&amp;err];   
  NSString *paramString = [[NSString alloc] initWithData:paramData encoding:NSUTF8StringEncoding];
  NSDictionary *param = @{@"data":paramString};
  AFHTTPRequestOperation *operation = [manager POST:URLString parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
      if (successBlock) {
          successBlock(responseObject);
      }
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
      DebugLog(@"%zd", operation.response.statusCode);
      if (failureBlock) {
          failureBlock(operation, error);
      }
  }];
  </code></pre>
  
  <hr>
  
  <p>But the request from <code>Fetch API</code> version is like this:</p>
  
  <p><a href="https://i.stack.imgur.com/ouZSD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ouZSD.png" alt="fetch POST"></a></p>
  
  <p>Code snippet:</p>
  
  <pre><code>export default async (url, param) =&gt; {
    var result = await fetch(url, {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'text/html',
      },
      body: JSON.stringify({ 
        'data': JSON.stringify(param) 
      })
    })
    .then(response =&gt; checkStatus(response))
    .then(response =&gt; response.json())
    .catch(e =&gt; { throw e; });
  
    return result;
  }
  </code></pre>
  
  <hr>
  
  <p>My question is how can I send a post in <code>fetch</code> exactly as in <code>AFNetworking</code>? This cost me a lot of time. Thx!!</p>
  
  <p><strong>updated:</strong> The main difference is the annoying slashes and their body data structure, native one is json (<code>data</code>: <code>paramString</code>), while js string.</p>