如何将数据从Angle 6发送到节点服务器?

时间:2018-08-03 10:02:45

标签: html node.js angular server angular6

我正在尝试将数据从角度6发送到nodeserver。我已经使用http.post传递数据了,并且我还没有使用Auth.Token函数和所有功能。但仍然在浏览器中出现错误,例如

我的component.ts:

 function(){
     return this.http.post('http://localhost/postdata', data, httpOptions).subscribe(result => {
       console.log(result);
     }, error => console.error('There was an error: ',error.message));

  }

我的服务器:

 app.post('/postdata', function (req, res) {
   console.log("hi there");
 });


"TypeError: this.getAuthToken is not a function
at Object.push../src/app/_network/HttpInterceptor.ts.InterceptedHttp.addAuthHeaders (HttpInterceptor.ts:45)
at Object.push../src/app/_network/HttpInterceptor.ts.InterceptedHttp.intercept (HttpInterceptor.ts:31)
at InterceptedHttp.value [as intercept] (Logger.class.ts:7)
at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http.js:1137)
at HttpXsrfInterceptor.push../node_modules/@angular/common/fesm5/http.js.HttpXsrfInterceptor.intercept (http.js:1748)
at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http.js:1137)
at HttpInterceptingHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptingHandler.handle (http.js:1788)
at MergeMapSubscriber.project (http.js:974)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:60)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:50)" 

对角度6完全陌生。有人可以帮助解决此问题吗?

0 个答案:

没有答案