Advertisement
Guest User

Untitled

a guest
Sep 6th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public login(username: string, password: string): Observable<LoginResponse> {
  2.  
  3. // this just encodes the data
  4. let data = this.formEncode({
  5. username: username,
  6. password: password
  7. })
  8.  
  9. let headers: HttpHeaders = new HttpHeaders()
  10. .set('Content-Type', 'application/x-www-form-urlencoded')
  11. // i've also tried below, but it didn't work
  12. // .set('Access-Control-Expose-Headers', 'X-Custom-Header-Name')
  13.  
  14. return this.http.post<LoginResponse>(
  15. ["www.foobar.com", "users", "login"].join("/"),
  16. data,
  17. {
  18. headers: headers,
  19. observe: 'response'
  20. }
  21. )
  22. .map((res) => {
  23. console.log(res)
  24. console.log(res.headers.getAll('Content-Type'))
  25. console.log(res.headers.getAll('Set-Cookie'))
  26. console.log(res.headers.getAll('X-Custom-Header-Name'))
  27. console.log(res.headers.keys())
  28. return res.body
  29. })
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement