Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login () {
- const data = {
- username: this.state.username,
- password: this.state.password
- }
- const options = {
- method: 'POST',
- body: JSON.stringify(data),
- headers: {
- 'Content-Type': 'application/json',
- credentials: 'include' // tried this too.
- // credentials: 'same-origin'
- }
- }
- fetch('/login', options)
- .then(res => {
- console.log('res', res)
- // cookies.set('connect.sid', document.cookie['connect.sid'])
- console.log(document.cookie['connect.sid'])// undefined
- console.log(res.headers) // empty
- console.log(document.cookies) // undefined
- // cookies.set('connect.sid', res.headers) // need to set this but where is the cookie from server?
- })
- .then(this.clearInputFields.bind(this))
- }
- HTTP/1.1 200 OK
- x-powered-by: Express
- content-type: text/html; charset=utf-8
- content-length: 14
- etag: W/"e-Xft1SGvF5rPEfqfROtKDA2epBao"
- set-cookie: connect.sid=s%3ACRnk3A0b0o5T8VSQTVpvTUgW54lO38IJ.skdIbmipmb1CGn6oEQ5KzdS2zGdNiZQrFDwU5cTuy7A; Path=/
- date: Tue, 05 Jun 2018 00:32:15 GMT
- connection: close
- Vary: Accept-Encoding
Add Comment
Please, Sign In to add comment