什么可能导致Nativescript angular2失败的承诺? [英] What could cause a promise to fail in Nativescript angular2?
问题描述
我正在尝试从数据库中获取Http GET,在那里我可以访问并可以在Postman中重现GET结果。
I am trying to Http GET from a database , where I do have access and can reproduce the GET result in Postman.
我已经在angular2 {N}中创建了一个服务,我执行此GET但是出现错误:
I have created a service in angular2 {N} where I execute this GET but I get an error of :
JS: EXCEPTION: Error: Uncaught (in promise): Response with status: 200 for URL: null
JS: STACKTRACE:
JS: Error: Uncaught (in promise): Response with status: 200 for URL: null
JS: at resolvePromise (/data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:496:32)
JS: at resolvePromise (/data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:481:18)
JS: at /data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:529:18
JS: at ZoneDelegate.invokeTask (/data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:314:38)
JS: at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (/data/data/org.nativescript.ndemo/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js:37:41)
JS: at ZoneDelegate.invokeTask (/data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:313:43)
JS: at Zone.runTask (/data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:214:48)
JS: at drainMicroTaskQueue (/data/data/org.nativescript.ndemo/files/app/tns_modules/zone.js/dist/zone-node.js:432:36)
JS: Unhandled Promise rejection: Response with status: 200 for URL: null ; Zone: angular ; Task: Promise.then ; Value: Response with status: 200 for URL: null
JS: Error: Uncaught
(in promise): Response with status: 200 for URL: null
我的服务:
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
export function createNonJsonResponse(http: Http, fullUrl: string): Promise<string>{
return http.get(fullUrl)
.toPromise()
.then(response => response.text())
// .catch(this.handleError);
}
我已经记录了给出的URL和Http,他们没事。
我不知道为什么会这样,谷歌无法帮助我找到任何解决方案。
I have logged both the URL given in and the Http and they are fine. I have no idea why is this happening and google couldn't help me find any solutions whatsoever.
推荐答案
它似乎,至少对我来说,@ angular / core Http模块没有按预期工作。我切换到nativescript的Http服务( https://docs.nativescript.org/cookbook/http 并设法完成我所需要的而没有任何问题。
It seems, at least for me, @angular/core Http module is not working as intended. I switched to the nativescript's Http service (https://docs.nativescript.org/cookbook/http) and managed to accomplish what I needed without any problems.
这篇关于什么可能导致Nativescript angular2失败的承诺?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!