Ionic 2 failed to make API call to Paypal

I want to write a http request in Ionic 2 to call API in Paypal and get the Http response for further processing. The API via curl is like following (

curl \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer accessToken" //assume accessToken=1234

The following is my code:

 let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Authorization', 'Bearer 1234'); //accessToken=1234
    var response ='',"null",{headers: headers}).map(res=>res.json());
      console.log(JSON.stringify(data)); //I need to get the HTTP response data for further processing.

However, the console said “500 (Internal Server Error)”.

So, could anyone please help me? thank you.

What does the request sent out by your app look?
Is it identical to the one curl creates?

(Quick way to find out is use a mitm proxy like Charles Web Proxy or fiddler)

I want to make this call is because I want to verify the Paypal payment in my app. So in this stage, I just want to know how to implement that curl command in my Ionic app, that’s why I created above http request code. Those codes will be sent out by just pressing a button in my app and then I want to console log the response. However, the console said “500 internal server error”. So do you have any idea to implement the above curl command in Ionic app? thanks

Check your sending data or getting data from API(Server Date) Or Check your Parameter field name

Yes, answer the questions I posted and do what I suggest you to do. I won’t write the code for you, put am happy to help you resolve the problem yourself. Doing what I wrote is the next step in that.