美文网首页
TypeError: error.json is not a f

TypeError: error.json is not a f

作者: 雪菲幂 | 来源:发表于2017-05-20 13:28 被阅读0次

import{ User}from'./user.model'

import{Injectable}from'@angular/core'

import{Http,Headers,Response}from"@angular/http";

import'rxjs/Rx';

import{Observable}from'rxjs';

@Injectable()

export classAuthService {

constructor(privatehttp: Http) {}

signup(user: User) {

constbody = JSON.stringify(user);

constheaders =newHeaders({'Content-Type':'application/json'});

return this.http.post('http://localhost:3000/user',body,{headers: headers})

.map((response: Response) => {returnresponse.json()})

.catch((error: Response) => Observable.throw(error.json()));

}

}

浏览器出现“TypeError: error.json is not a function”,但是http请求发送成功 

解决方法

检查前后端的router的地址是否遗漏出错

相关文章

网友评论

      本文标题:TypeError: error.json is not a f

      本文链接:https://www.haomeiwen.com/subject/lycpxxtx.html