Promise Error Handling
- Some asynchronous operations can fail (especially network operations)
- Promises have a
.catch
method to handle errors - This cannot be done in a normal try / catch block because the code has moved on
fetch("https://some-site.com")
.then(resp => resp.json())
.then(data => console.log(data))
.catch(e => console.error("Oh no! There was an error!"))
9 / 23