Skip to content

Commit

Permalink
fixed products
Browse files Browse the repository at this point in the history
  • Loading branch information
Neel Mazumdar committed May 28, 2020
1 parent 8201206 commit b8288a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# back-end
Back End of African Marketplace III

Endpoints:

POST: api/auth/register
POST: api/auth/login
GET: api/users
GET: api/users/id

GET: api/products
GET: api/products/id
POST: api/products
PUT: api/products/id
DELETE: api/products/id
Binary file modified data/auth.db3
Binary file not shown.
9 changes: 6 additions & 3 deletions products/products-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ function find() {
}

function add(product) {
const [id] = db("products").insert(product, "id");

return findById(id);
return db("products")
.insert(product, "id")
.then(ids => {
const [id] = ids;
return findById(id);
});
}

function findById(id) {
Expand Down

0 comments on commit b8288a1

Please sign in to comment.