Skip to content

Instantly share code, notes, and snippets.

@proseLA
proseLA / connectAndPrint.js
Created July 31, 2018 15:16 — forked from tresf/connectAndPrint.js
Connect and print
function connectAndPrint() {
// our promise chain
connect().then(function() {
return print();
}).then(function() {
success(); // exceptions get thrown all the way up the stack
}).catch(fail); // so one catch is often enough for all promises
// NOTE: If a function returns a promise, you don't need to wrap it in a fuction call.
// The following is perfectly valid: