Reputation: 2009
I just updated angular and this doesn't work anymore. I get this error: TypeError: Cannot read property 'get' of undefined. The .get function seems to no longer work. Any ideas?
this.http.post(this.baseUrl + 'users/login', body, {
headers: headers
})
.map((res:any) => res.headers._headersMap.get('auth'))
.catch(this.handleError);
Upvotes: 0
Views: 462
Reputation: 40946
Use .get()
on the headers
object directly:
res.headers.get('auth')
You will get much more help from your IDE (autocomplete) if you correctly indicate the type of res
import {Response} from '@angular/http';
...
this.http.post(...)
.map((res:Response) => res.headers.get('auth'))
...
Upvotes: 2