Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Express HTTP post在postman上工作,但在Angular 2上不工作_Express_Angular_Angular2 Forms_Angular2 Services - Fatal编程技术网

Express HTTP post在postman上工作,但在Angular 2上不工作

Express HTTP post在postman上工作,但在Angular 2上不工作,express,angular,angular2-forms,angular2-services,Express,Angular,Angular2 Forms,Angular2 Services,我有一个模板(单击)triggets addUseCase(): 在Postman中进行测试后,我得到了node/express服务器的正确响应。但当我尝试使用angular HTTP发送时,我根本没有收到任何响应,没有错误: 我的邮递员可以工作,但无法使angular 2的http post工作: 更新时出现错误: 以及错误: EXCEPTION: Unexpected token W in JSON at position 0ErrorHandler.handleError @ core.

我有一个模板(单击)triggets addUseCase():

在Postman中进行测试后,我得到了node/express服务器的正确响应。但当我尝试使用angular HTTP发送时,我根本没有收到任何响应,没有错误:

我的邮递员可以工作,但无法使angular 2的http post工作:

更新时出现错误: 以及错误:

EXCEPTION: Unexpected token W in JSON at position 0ErrorHandler.handleError @ core.umd.js:3462next @ core.umd.js:6924schedulerFn @ core.umd.js:6172SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6164onError @ core.umd.js:6388onHandleError @ core.umd.js:6263ZoneDelegate.handleError @ zone.js:236Zone.runTask @ zone.js:157ZoneTask.invoke @ zone.js:335
core.umd.js:3467 ORIGINAL STACKTRACE:ErrorHandler.handleError @ core.umd.js:3467next @ core.umd.js:6924schedulerFn @ core.umd.js:6172SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6164onError @ core.umd.js:6388onHandleError @ core.umd.js:6263ZoneDelegate.handleError @ zone.js:236Zone.runTask @ zone.js:157ZoneTask.invoke @ zone.js:335
core.umd.js:3468 SyntaxError: Unexpected token W in JSON at position 0
    at JSON.parse (<anonymous>)
    at Function.Json.parse (http://localhost:3000/vendor.bundle.js:11272:59)
    at Response.Body.json (http://localhost:3000/vendor.bundle.js:12250:30)
    at MapSubscriber.project (http://localhost:3000/main.bundle.js:6202:47)
    at MapSubscriber._next (http://localhost:3000/vendor.bundle.js:23914:36)
    at MapSubscriber.Subscriber.next (http://localhost:3000/vendor.bundle.js:249:19)
    at XMLHttpRequest.onLoad (http://localhost:3000/vendor.bundle.js:12581:43)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:14882:36)
    at Object.onInvokeTask (http://localhost:3000/vendor.bundle.js:6930:42)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:14881:41)
  -------------   Elapsed: 16 ms; At: Thu Oct 27 2016 08:06:32 GMT-0500 (COT)   -------------  
    at Object.onScheduleTask (http://localhost:3000/polyfills.bundle.js:14537:19)
    at ZoneDelegate.scheduleTask (http://localhost:3000/polyfills.bundle.js:14859:50)
    at Zone.scheduleEventTask (http://localhost:3000/polyfills.bundle.js:14791:40)
    at zoneAwareAddListener (http://localhost:3000/polyfills.bundle.js:15441:15)
    at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:3000/polyfills.bundle.js:15544:18), <anonymous>:3:43)
    at Observable._subscribe (http://localhost:3000/vendor.bundle.js:12624:23)
    at Observable.subscribe (http://localhost:3000/vendor.bundle.js:70:28)
    at Observable._subscribe (http://localhost:3000/vendor.bundle.js:128:29)ErrorHandler.handleError @ core.umd.js:3468next @ core.umd.js:6924schedulerFn @ core.umd.js:6172SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6164onError @ core.umd.js:6388onHandleError @ core.umd.js:6263ZoneDelegate.handleError @ zone.js:236Zone.runTask @ zone.js:157ZoneTask.invoke @ zone.js:335
http.umd.js:188 Uncaught SyntaxError: Unexpected token W in JSON at position 0(…)Json.parse @ http.umd.js:188Body.json @ http.umd.js:1166(anonymous function) @ add.component.ts:34MapSubscriber._next @ map.js:77Subscriber.next @ Subscriber.js:89onLoad @ http.umd.js:1497ZoneDelegate.invokeTask @ zone.js:265onInvokeTask @ core.umd.js:6233ZoneDelegate.invokeTask @ zone.js:264Zone.runTask @ zone.js:154ZoneTask.invoke @ zone.js:335
异常:位置0ErrorHandler.handleError@core.umd.js:3462next@core.umd.js:6924schedulerFn@core.umd.js:6172SafeSubscriber.\uu tryorunsubscriber@Subscriber.js:223SafeSubscriber.next@Subscriber.js:172Subscriber.\u next@Subscriber.js:125Subscriber.next@Subscriber.js:89Subject.next@Subject.js:55EventEmitter.emit@core.umd.js:6164onError@core.umd.js:6388onHandleError@core.umd.js:6263ZoneDelegate.handleError@zone.js:236Zone.runTask@zone.js:157ZoneTask.invoke@zone.js:335
core.umd.js:3467原始STACKTRACE:ErrorHandler.handleError@core.umd.js:3467next@core.umd.js:6924schedulerFn@core.umd.js:6172安全订户。uu tryorunsubscriber@Subscriber.js:223SafeSubscriber.next@Subscriber.js:172Subscriber.next@Subscriber.js:125Subscriber.next@Subscriber.js:89Subject.next@Subject.js:Subject.js:55EventEmitter@core.umd.js:6164onError@core.umd.js:6388onHandleError@core.umd.js:6263ZoneDelegate.handleError@zone.js:236Zone.runTask@zone.js:157ZoneTask.invoke@zone.js:335
core.umd.js:3468语法错误:JSON中位于位置0的意外标记W
在JSON.parse()处
在Function.Json.parse(http://localhost:3000/vendor.bundle.js:11272:59)
在Response.Body.json(http://localhost:3000/vendor.bundle.js:12250:30)
在MapSubscriber.project上(http://localhost:3000/main.bundle.js:6202:47)
在MapSubscriber.\u下一步(http://localhost:3000/vendor.bundle.js:23914:36)
在MapSubscriber.Subscriber.next(http://localhost:3000/vendor.bundle.js:249:19)
在XMLHttpRequest.onLoad时(http://localhost:3000/vendor.bundle.js:12581:43)
在ZoneDelegate.invokeTask(http://localhost:3000/polyfills.bundle.js:14882:36)
在Object.onInvokeTask(http://localhost:3000/vendor.bundle.js:6930:42)
在ZoneDelegate.invokeTask(http://localhost:3000/polyfills.bundle.js:14881:41)
-------------经过时间:16毫秒;时间:2016年10月27日星期四08:06:32 GMT-0500(COT)----
在Object.onScheduleTask(http://localhost:3000/polyfills.bundle.js:14537:19)
在ZoneDelegate.scheduleTask(http://localhost:3000/polyfills.bundle.js:14859:50)
在Zone.scheduleEventTask上(http://localhost:3000/polyfills.bundle.js:14791:40)
在ZoneaweaddListener(http://localhost:3000/polyfills.bundle.js:15441:15)
在XMLHttpRequest.addEventListener处(在createNamedFn处求值(http://localhost:3000/polyfills.bundle.js:15544:18), :3:43)
在可观察的情况下(http://localhost:3000/vendor.bundle.js:12624:23)
在可观察的时刻(http://localhost:3000/vendor.bundle.js:70:28)
在可观察的情况下(http://localhost:3000/vendor.bundle.js:128:29)ErrorHandler.handleError@core.umd.js:3468next@core.umd.js:6924schedulerFn@core.umd.js:6172SafeSubscriber.\uu tryorunsubscriber@Subscriber.js:223SafeSubscriber.next@Subscriber.js:125Subscriber.next@Subscriber.js:89Subject.next@Subject.js:55emit@core.umd.js:6164onError@core.umd.js:6388onHandleError@core.umd.js:6263ZoneDelegate.handleError@zone.js:236Zone.runTask@zone.js:157ZoneTask.invoke@zone.js:335
http.umd.js:188未捕获语法错误:JSON中位置0(…)处的意外标记W JSON.parse@http.umd.js:188Body.JSON@http.umd.js:1166(匿名函数)@add.component.ts:34MapSubscriber._next@map.js:77Subscriber.next@Subscriber.js:89onLoad@http.umd.js:1497ZoneDelegate.invokeTask@zone.js:265onInvokeTask@core.umd.js:6233ZoneDelegate.invokeTask@zone.js:264 zone.runTask@zone.js:154ZoneTask.invoke@zone.js:335

您从未订阅过Observable。在您这样做之前,不会提出任何请求

this.http.post(url, body, {headers: headers})
  .map(res => res.text()).subscribe(data => console.log(data));

您是否有任何错误?您从未订阅observable@peeskillet如何使用?
.map(res=>res.json()).subscribe(data=>console.log(data))
@peeskillet,谢谢你,至少我遇到了错误,请查看更新
EXCEPTION: Unexpected token W in JSON at position 0ErrorHandler.handleError @ core.umd.js:3462next @ core.umd.js:6924schedulerFn @ core.umd.js:6172SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6164onError @ core.umd.js:6388onHandleError @ core.umd.js:6263ZoneDelegate.handleError @ zone.js:236Zone.runTask @ zone.js:157ZoneTask.invoke @ zone.js:335
core.umd.js:3467 ORIGINAL STACKTRACE:ErrorHandler.handleError @ core.umd.js:3467next @ core.umd.js:6924schedulerFn @ core.umd.js:6172SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6164onError @ core.umd.js:6388onHandleError @ core.umd.js:6263ZoneDelegate.handleError @ zone.js:236Zone.runTask @ zone.js:157ZoneTask.invoke @ zone.js:335
core.umd.js:3468 SyntaxError: Unexpected token W in JSON at position 0
    at JSON.parse (<anonymous>)
    at Function.Json.parse (http://localhost:3000/vendor.bundle.js:11272:59)
    at Response.Body.json (http://localhost:3000/vendor.bundle.js:12250:30)
    at MapSubscriber.project (http://localhost:3000/main.bundle.js:6202:47)
    at MapSubscriber._next (http://localhost:3000/vendor.bundle.js:23914:36)
    at MapSubscriber.Subscriber.next (http://localhost:3000/vendor.bundle.js:249:19)
    at XMLHttpRequest.onLoad (http://localhost:3000/vendor.bundle.js:12581:43)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:14882:36)
    at Object.onInvokeTask (http://localhost:3000/vendor.bundle.js:6930:42)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:14881:41)
  -------------   Elapsed: 16 ms; At: Thu Oct 27 2016 08:06:32 GMT-0500 (COT)   -------------  
    at Object.onScheduleTask (http://localhost:3000/polyfills.bundle.js:14537:19)
    at ZoneDelegate.scheduleTask (http://localhost:3000/polyfills.bundle.js:14859:50)
    at Zone.scheduleEventTask (http://localhost:3000/polyfills.bundle.js:14791:40)
    at zoneAwareAddListener (http://localhost:3000/polyfills.bundle.js:15441:15)
    at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:3000/polyfills.bundle.js:15544:18), <anonymous>:3:43)
    at Observable._subscribe (http://localhost:3000/vendor.bundle.js:12624:23)
    at Observable.subscribe (http://localhost:3000/vendor.bundle.js:70:28)
    at Observable._subscribe (http://localhost:3000/vendor.bundle.js:128:29)ErrorHandler.handleError @ core.umd.js:3468next @ core.umd.js:6924schedulerFn @ core.umd.js:6172SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.umd.js:6164onError @ core.umd.js:6388onHandleError @ core.umd.js:6263ZoneDelegate.handleError @ zone.js:236Zone.runTask @ zone.js:157ZoneTask.invoke @ zone.js:335
http.umd.js:188 Uncaught SyntaxError: Unexpected token W in JSON at position 0(…)Json.parse @ http.umd.js:188Body.json @ http.umd.js:1166(anonymous function) @ add.component.ts:34MapSubscriber._next @ map.js:77Subscriber.next @ Subscriber.js:89onLoad @ http.umd.js:1497ZoneDelegate.invokeTask @ zone.js:265onInvokeTask @ core.umd.js:6233ZoneDelegate.invokeTask @ zone.js:264Zone.runTask @ zone.js:154ZoneTask.invoke @ zone.js:335
this.http.post(url, body, {headers: headers})
  .map(res => res.text()).subscribe(data => console.log(data));