response with status 200: ok

时间秒杀一切 提交于 2019-12-11 05:28:35

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/38579646/response-with-status-200-ok

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!