Guest User

Untitled

a guest
Jun 4th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. login () {
  2. const data = {
  3. username: this.state.username,
  4. password: this.state.password
  5. }
  6.  
  7. const options = {
  8. method: 'POST',
  9. body: JSON.stringify(data),
  10. headers: {
  11. 'Content-Type': 'application/json',
  12. credentials: 'include' // tried this too.
  13. // credentials: 'same-origin'
  14. }
  15. }
  16.  
  17. fetch('/login', options)
  18. .then(res => {
  19. console.log('res', res)
  20. // cookies.set('connect.sid', document.cookie['connect.sid'])
  21. console.log(document.cookie['connect.sid'])// undefined
  22. console.log(res.headers) // empty
  23. console.log(document.cookies) // undefined
  24. // cookies.set('connect.sid', res.headers) // need to set this but where is the cookie from server?
  25. })
  26. .then(this.clearInputFields.bind(this))
  27. }
  28.  
  29. HTTP/1.1 200 OK
  30. x-powered-by: Express
  31. content-type: text/html; charset=utf-8
  32. content-length: 14
  33. etag: W/"e-Xft1SGvF5rPEfqfROtKDA2epBao"
  34. set-cookie: connect.sid=s%3ACRnk3A0b0o5T8VSQTVpvTUgW54lO38IJ.skdIbmipmb1CGn6oEQ5KzdS2zGdNiZQrFDwU5cTuy7A; Path=/
  35. date: Tue, 05 Jun 2018 00:32:15 GMT
  36. connection: close
  37. Vary: Accept-Encoding
Add Comment
Please, Sign In to add comment