Skip to content

Instantly share code, notes, and snippets.

@gaurangrshah
Last active April 12, 2021 18:51
Show Gist options
  • Save gaurangrshah/4118fa0a066d79bf6c1e59f77635e610 to your computer and use it in GitHub Desktop.
Save gaurangrshah/4118fa0a066d79bf6c1e59f77635e610 to your computer and use it in GitHub Desktop.
export function handlePromises(promises = []) {
return Promise.all(promises)
.then((responses) => {
console.log('handlePromises Success', responses);
return responses;
})
.catch((error) =>
console.log(
`handlePromises Error ${JSON.stringify(error, null, 2)}`
)
);
}
function waitAtLeast (time, promise) {
const timeoutPromise = new Promise((resolve) => {
setTimeout(resolve, time)
})
return Promise.all([promse, timeoutPromise]).then((values) => values[0])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment