Permalink
Browse files

Make promise format consistent

Close ga-wdi-boston#10
Fix typo:
Close ga-wdi-boston#11
  • Loading branch information...
racheltstevens
racheltstevens committed Feb 27, 2017
1 parent 09e022f commit 58d750a2ad1971161d651f5b092d8e5161d0cccf
Showing with 11 additions and 9 deletions.
  1. +11 −9 README.md
@@ -96,18 +96,19 @@ const readJSON = function (filename) { // <-- look here
resolve(res); resolve(res);
} }
}); });
}).then((res) => { })
.then((res) => {
return JSON.parse(res) return JSON.parse(res)
}); });
}; };
readJSON('./example.json') readJSON('./example.json')
.then((pojo) => { .then((pojo) => {
callback(pojo); // do something with the object callback(pojo); // do something with the object
}) })
.catch((err) => { // handle error conditions .catch((err) => { // handle error conditions
console.error(err); console.error(err);
}); });
``` ```


That's too verbose. This is better: That's too verbose. This is better:
@@ -124,11 +125,12 @@ const readJSON = function (filename) {
}); });
}) })
.then(JSON.parse); // what can we surmise about .then? .then(JSON.parse); // what can we surmise about .then?
};
readJSON('./example.json') readJSON('./example.json')
.then(callback) // do something with the object .then(callback) // do something with the object
.catch(console.error); // handle error conditions .catch(console.error); // handle error conditions
``` ```


### Code-Along: Promisify `copy-json.js` ### Code-Along: Promisify `copy-json.js`

0 comments on commit 58d750a

Please sign in to comment.