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)) }) }) } }