Skip to content

Instantly share code, notes, and snippets.

@hanipcode
Created September 18, 2018 14:30
Show Gist options
  • Save hanipcode/7bcff33af146d870cdb3b8aef72d0e1a to your computer and use it in GitHub Desktop.
Save hanipcode/7bcff33af146d870cdb3b8aef72d0e1a to your computer and use it in GitHub Desktop.
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