Advertisement
Guest User

Untitled

a guest
May 18th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. let config = {
  2. method: 'POST',
  3. headers: {
  4. "Accept": "application/json",
  5. "Content-Type": "application/json"
  6. },
  7. body: JSON.stringify(creds) // { email: 'asd@example.org', password: 'asdasdasd' }
  8. }
  9.  
  10. return dispatch => {
  11. dispatch(requestLogin(creds))
  12. return fetch('http://localhost:3000/auth/sign_in', config)
  13. .then(response =>
  14. response.json()
  15. .then(user => ({ user, response }))
  16. ).then(({ user, response }) => {
  17. if (!response.ok) {
  18. // ...
  19. }
  20. else {
  21. console.log(response.headers.get('access-token')) // => null
  22. }
  23. }).catch(err => console.log("Error: ", err))
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement