Skip to content

Instantly share code, notes, and snippets.

@stevenvachon
Last active June 4, 2019 22:45
Show Gist options
  • Save stevenvachon/1d9eb1e57200add4e106053778f4ac8c to your computer and use it in GitHub Desktop.
Save stevenvachon/1d9eb1e57200add4e106053778f4ac8c to your computer and use it in GitHub Desktop.
Compare these
try {
const resumes = await this.getResumes();
if (resumes.length > 0) {
this.setState({
resume: await this.getResume(resumes[0])
});
}
} catch(error) {
console.error(error);
} finally {
this.setState({isLoading: false});
}
this.getResumes()
.then(resumes => {
if (resumes.length > 0) {
return this.getResume(resumes[0]).then(resume => this.setState({resume}));
}
})
.catch(error => console.error(error))
.finally(() => this.setState({isLoading: false}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment