Trying to use native http but it's not working


#1

Below is my code. It’s just returning undefined:

    this.http.post(
      'https://abcd.com/request.api',
      JSON.stringify(requestData),
      {
        'Content-Type': 'application/json'
      }
    )
    .then(data => {
  
      console.log(data.status);
      console.log(data.data); // data received by server
      console.log(data.headers);
  
    })
    .catch(error => {
  
      console.log(error.status);
      console.log(error.error); // error message as string
      console.log(error.headers);
  
    });

#2

Try
console.log(JSON.stringify(data.status));
console.log(JSON.stringify(data.data));
console.log(JSON.stringify(data.headers));

Hope it may work


#3

Same Result:


#4

first check whether data is coming or not.

try console.log(data) and check any response is coming


#5

Checked by PostMan extension. Data is coming


#6

check with headers what has to pass to url…


#7

Getting this response now


#8

is it working now?..


#9


#10

use this plugin https://ionicframework.com/docs/native/status-bar/