Я попытался сделать вызов http.get()
с помощью этих двух методов.
Первый:
getResults(){
return this.http.get('http://localhost/api.php')
.toPromise()
.then( data => data.json() );
}
Показана ошибка:
3 122412 error EXCEPTION: Uncaught (in promise): Response with status:0 for URL: null
4 122413 error ORIGINAL STACKTRACE:
5 122413 error Error: Uncaught (in promise): Response with status: 0 for URL: null
..........
Второй:
getResults(){
return new Promise((resolve, reject) => {
this.http.get('http://localhost/api.php')
.map(res => res.json())
.subscribe(data => {
resolve(data);
}, (err) => {
reject(err);
});
});
}
Показана ошибка:
2 925052 error EXCEPTION: Uncaught (in promise): Response with status:0 for URL: null
3 925052 error ORIGINAL STACKTRACE:
4 925053 error Error: Uncaught (in promise): Response with status: 0 for URL: null
.......
Какой метод выбрать и в чем может быть проблема?