Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let config = {
- method: 'POST',
- headers: {
- "Accept": "application/json",
- "Content-Type": "application/json"
- },
- body: JSON.stringify(creds) // { email: 'asd@example.org', password: 'asdasdasd' }
- }
- return dispatch => {
- dispatch(requestLogin(creds))
- return fetch('http://localhost:3000/auth/sign_in', config)
- .then(response =>
- response.json()
- .then(user => ({ user, response }))
- ).then(({ user, response }) => {
- if (!response.ok) {
- // ...
- }
- else {
- console.log(response.headers.get('access-token')) // => null
- }
- }).catch(err => console.log("Error: ", err))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement