Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] try to solve postproduct with promise #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xIrusux
Copy link
Contributor

@xIrusux xIrusux commented Sep 22, 2019

No description provided.

prodName = "'" + prodName + "'";
console.log("prodname + quotes", prodName);
getProductByName(prodName);
}).then(id => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing is being returned by this arrow function. .then() is only a function of a promise as such you would need to have this arrow function return a promise explicitly by creating it directly:

.then() => {
  return new Promise ((resolve, reject) => {
   ... rest of code

but there is no need as the getProductsByName(prodName) call is returning connection.query (which is this essentially http://vitaly-t.github.io/pg-promise/Database.html#query) and so is returning a promise. So you can just return that on line 28
return getProductByName(prodName) so that the promise returned by connection.query gets returned by that and it can be used in the .then() on line 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants