这是我的代码。
this.jsonp.request(url, { method: 'Get' })
.map(res => res.json()})
.subscribe(
data => {
//success code
},
error => {
//error code
}
)
问题是该函数总是执行错误代码块。在浏览器中,响应是200 ok。
答案 0 :(得分:0)
Note: import Httpmodule and inject to appmodule
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
......
......
public http: Http,
.....
......
let url="http://XXXX.XXXXX.XXXXX/1/forms";//put URL of JSON here
this.http.get(url).map(res => res.json()).subscribe(resp => {
console.log(resp);
});