I\'m trying to understand Promises from the MDN documentation. The first example demonstrates the then and catch methods:
then
catch
// We def
This:
var p2 = p1.then() p2.catch()
is the same as this:
p1.then().catch()
You can also do this:
p1 .then(response => response.body) .then(body => JSON.parse(body)) .then(data => console.log(data)) .catch(e => console.log('something somewhere failed'))