response with status 200: ok

2019-07-26 22:13发布

I am trying to figure out how to plot data from a local '.JSON' file using angular2-highcharts example.

I followed the example in 'https://www.npmjs.com/package/angular2-highcharts' to first understand how to plot .JSON data and it worked. I took the data available for the example and created a local .JSON file (copied the content from 'https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK' in notepad and saved it with UTF-8 encoding as a .JSON file), and replaced the file path for the JSON request to this. When I do this though, I get an error - response with status 200.

  constructor(jsonp : Jsonp) {
    //jsonp.get('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK').subscribe(res => {
        jsonp.get('./data.json').subscribe(res => {
        this.options = {
            title : { text : 'AAPL Stock Price' },
           series : [{
               name : 'AAPL',
               data : res.json(),
              tooltip: {
                   valueDecimals: 2
              }
         }]
        };
    });
}
options: Object;
};

Since I am not super familiar with json data/ Javascript or angular2 I am not sure if I am missing something very basic here. Any help is appreciated.

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-07-26 22:26

Using http instead of json helped. I made use of the suggestion in this answer https://stackoverflow.com/a/36305814/4567096.

查看更多
Juvenile、少年°
3楼-- · 2019-07-26 22:42

as far as I know, Response Status 200 specifies that request was successful. i.e. your request was successfully handled. perhaps you want to try checking response data.

check your callback for response data.

查看更多
登录 后发表回答