Skip to content

Instantly share code, notes, and snippets.

@gktaj
gktaj / index.md
Created July 30, 2019 09:42 — forked from gnapse/index.md
Promise vs async/await

then(onSuccess).catch(onFailure)

This one catches errors not only during the ajax request, but during the onSuccess handler execution.

const response = ajax(options).then(onSuccess).catch(onFailure)

The appropriate translation to async/await could be something like this: