TypeError: error.json is not a function

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 function)