Created
April 10, 2019 01:16
-
-
Save gugat/2adf5f574a04c6c40000d5042b1231c4 to your computer and use it in GitHub Desktop.
Revisions
-
gugat created this gist
Apr 10, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ export const signIn = (email, password) => { return (dispatch, getState) => { return new Promise((resolve, reject) => { return fetch(`${BASE_URL}/auth/sign_in`, { method: 'POST', timeout: REQUEST_TIMEOUT, headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email, password }), }) .then(handleFetchErrors) .then(res => res.json().then(json => ({ headers: res.headers, status: res.status, json }))) .then(({ headers, status, json }) => { const promises = getAvailableHeaders(headers) Promise.all(promises).then(credentials => { return resolve(true); }) }) .catch(error => { parseFetchError(error) .then(errorObject => reject(errorObject)) }) }) } }