This example has been corrected from the original version by replacing the semicolon after the connect function declaration with a comma and removing the semicolon after the query function declaration.
var db = {
connect: function () {/*...*/},
query: function () {/*...*/}
};
function getReportData() {
return db.connect().then(function (connection) {
return db.query(connection, 'select report data');
});
}
getReportData().then(function (data) {
data.sort();
console.log(data);
}).catch(function (err) {
console.log('Unable to show data');
});