Cannot parse JSON in response

Problem State: I calling post request using javaScript and in response i am expecting array of dictionary in JSON Format. here is my code.

let jsonData = JSON.stringify(params)
return this.http.post(this.baseUrl, jsonData , this.options)
.map(res => res.json()) 
.subscribe( data => {

    console.log(data);
    if (data != null){
      this.data = data

    }else{
      console.log(' Data is null')
    }
  },

   () => console.log('Call Complete')

 );

I also tried this piece of code too.

    return   this.http.get(this.baseUrl).map(res => res.json()[0]).subscribe(data => {
      this.data = data.data.children;
      console.log('response received');
      console.log(this.data);
  });

Can anyone find where is problem

What is your expected output and what are you getting?
And what is the error?

data sent to server successfully but i get this error: Response with status: 0 for url: null

25 PM

i am expecting : array of dictionary in json form

Where does this code live?

remove your which platform did you use. then try to run your project and see your output.

i am using ios platform

please remove it and re add ios platform. this is an one way solution

i write this code in provider.

Then I think subscribing there is a mistake. Providers should return Observables, possibly transformed, but should leave the subscribing to pages.

I hope here you are using http.get not http.post

I tried this l already but no luck until now

this.myheader = new Headers({
    'Access-Control-Allow-Origin' : '*',
    'Access-Control-Allow-Headers': '*',
    'Content-Type': 'application/json',
    'Accept': 'application/json; charset=utf-8',
    'Access-Control-Allow-Methods' : 'POST, GET, DELETE, OPTIONS, PUT',

  });
  this.options = new RequestOptions({ headers: this.myheader });

return this.http.get(this.baseUrl).map(res => res.json()).subscribe(data => {
      console.log(data);
  });

i get this error

@zahidshabbir92

is this.baseUrl a php file?
then add header('Access-Control-Allow-Origin: *'); on top in the PHP page.

Also run the url direcly on the browser(Firefox preferably) and see what you get?

if hit this url this.baseUrl directly it return response correctly.

what about this? did you try this?