title: How do i make a POST request to an api in React Native?
body: <p>I am trying to make a Post request to an api but for some reason i am getting a 400 feedback in the process. Being that i am a beginner at this, i can't really figure out where i am getting it wrong. I understand 400 error has to do with incorrect syntax but i am not sure that is the case here. I also checked out the other related posts but none helped address my problem. I have also read through the documentation over and over again but still can't see where i am making a mistake. I will appreciate if you helped me point out the problem.</p>
  <pre><code>  myPostRequest(){
      
      var mybody = { 
        &quot;amount&quot;: &quot;5.0&quot;,
        &quot;currency&quot;: &quot;EUR&quot;,
        &quot;externalId&quot;: &quot;6547864&quot;,
        &quot;payer&quot;: { &quot;partyIdType&quot;: &quot;MSISDN&quot;,&quot;partyId&quot;: &quot;0977948551&quot;}
      }
      mybody = JSON.stringify(mybody);
      var token = &quot;mytoken&quot;;   
      //POST request 
      fetch('https://sandbox.momodeveloper.mtn.com/collection/v1_0/requesttopay', {
        method: &quot;POST&quot;,
        headers: {
          'Authorization': 'Bearer '+token,
          'X-Reference-Id': 'f9b8b0a-XXXXXXXXXX',
          'X-Target-Environment': 'sandbox',
          'Ocp-Apim-Subscription-Key': '14d2a71dXXXXXXXXX',
        },
        body: mybody,
      })
      .then((responseJson) =&gt; {
          alert(JSON.stringify(responseJson));
          console.log(responseJson);
      })
      .catch((error) =&gt; {
        alert(JSON.stringify(error));
        console.error(error);
      });
    }
  </code></pre>