Created
November 6, 2018 17:40
-
-
Save tudorilisoi/5247ee0090f9648a7b98e6557ea72549 to your computer and use it in GitHub Desktop.
This file contains 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 characters
//dashboard reducer | |
export default (allLists = [], action) => { | |
switch (action.type) { | |
case 'DASHBORD_FETCH_SUCCESS': | |
return action.data | |
case 'DASHBORD_FETCH_ERROR': | |
return [] | |
default: | |
return allLists | |
} | |
} | |
export function fetchDashboard() { | |
return fetch(`${API_BASE_URL}/dashboard`, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
//token here | |
} | |
}) | |
.then(data => data.json()) | |
.then(dataObj => { | |
dispatch({ type: 'DASHBORD_FETCH_SUCCESS', data: dataObj }) | |
}).catch(err => { | |
dispatch({ type: 'DASHBORD_FETCH_ERROR' }) | |
}) | |
} | |
fetchDashboard() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment