Created
September 18, 2018 14:30
-
-
Save hanipcode/7bcff33af146d870cdb3b8aef72d0e1a to your computer and use it in GitHub Desktop.
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 characters
const deleteAfterHelper = (apiGetUser, otherRouteApiFunc, otherRouteApiParam) => { | |
return new Promise((resolve, reject) => { | |
// TODOS: Add error exception using reject (bisa ditambah sendiri) | |
apiGetUser().then((data) => { | |
const { userId } = data; | |
const finalParam = { | |
id: userId, | |
...otherRouteApiParam, | |
}; | |
otherRouteApiFunc().then((otherApiData) => { | |
resolve(otherApiData); | |
}); | |
}) | |
}) | |
} | |
// usage | |
deleteAfterHelper(apiGetUser, apiGetProduct); | |
deleteAfterHelper(apiGetUser, apiGetCart); | |
// etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment