Skip to content

Commit

Permalink
added bug fix where attempted to pass multiple things out of promise
Browse files Browse the repository at this point in the history
  • Loading branch information
iangeckeler committed Jul 8, 2019
1 parent f274582 commit f0aeefb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ class Client {
database
.query(createTable)
.then(res => {
resolve(database, done);
resolve({ database, done });
tableCreated = true;
})
.catch(e =>
reject(new Error("Error connecting to Postgres Pool."))
);
} else {
resolve(database, done);
resolve({ database, done });
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion postgres/create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function(userID, phone) {
return new Promise((resolve, reject) => {
this.pgConnect()
.then((pgDatabase, done) => {
.then(({ database, done }) => {
// pgClient.query... blah blah logic
//invoke done before your resolve this promise
console.log("called create");
Expand Down
10 changes: 8 additions & 2 deletions postgres/send.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
module.exports = function(userID, phone) {
return new Promise((resolve, reject) => {
this.pgConnect()
.then(pgDatabase => {
.then(({ database, done }) => {
// pgClient.query... blah blah logic
//invoke done before your resolve this promise
console.log("called create");
done();
})
.catch(err => reject(err));
.catch((err, done) => {
//invoke done before you reject
reject(err);
});
});
};
10 changes: 8 additions & 2 deletions postgres/verify.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
module.exports = function(userID, phone) {
return new Promise((resolve, reject) => {
this.pgConnect()
.then(pgDatabase => {
.then(({ database, done }) => {
// pgClient.query... blah blah logic
//invoke done before your resolve this promise
console.log("called create");
done();
})
.catch(err => reject(err));
.catch((err, done) => {
//invoke done before you reject
reject(err);
});
});
};

0 comments on commit f0aeefb

Please sign in to comment.