This commit is contained in:
@@ -53,6 +53,7 @@ const ProductModel = () => {
|
||||
};
|
||||
|
||||
const update = (product) => {
|
||||
console.log(product);
|
||||
const foundIdx = products.findIndex((obj) => {
|
||||
return obj._id === product._id;
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ app.post('/api/products', (req, res) => {
|
||||
return res.status(400).send({ msg: 'Could not add product', status: 400, success: false });
|
||||
}
|
||||
|
||||
res.send({ msg: 'Product added', status: 200, success: true, data: product });
|
||||
return res.send({ msg: 'Product added', status: 200, success: true, data: product });
|
||||
});
|
||||
|
||||
// HTTP - Methode - GET
|
||||
@@ -69,7 +69,7 @@ app.post('/api/products', (req, res) => {
|
||||
// (B)READ - browse
|
||||
app.get('/api/products', (req, res) => {
|
||||
const data = products.getAll();
|
||||
res.send(data);
|
||||
return res.send(data);
|
||||
});
|
||||
|
||||
// HTTP - Methode - GET
|
||||
@@ -83,7 +83,7 @@ app.get('/api/products/:id', (req, res) => {
|
||||
return res.status(400).send({ msg: 'Could not get product', status: 400, success: false });
|
||||
}
|
||||
|
||||
res.send(product);
|
||||
return res.send(product);
|
||||
});
|
||||
|
||||
// HTTP - Methode - PUT/PATCH
|
||||
@@ -98,7 +98,7 @@ app.put('/api/products', (req, res) => {
|
||||
return res.status(400).send({ msg: 'Could not update product', status: 400, success: false });
|
||||
}
|
||||
|
||||
res.send({ msg: 'Product updated', status: 200, success: true, data: product });
|
||||
return res.send({ msg: 'Product updated', status: 200, success: true, data: product });
|
||||
});
|
||||
|
||||
// HTTP - Methode - DELETE
|
||||
@@ -111,7 +111,7 @@ app.delete('/api/products/:id', (req, res) => {
|
||||
return res.status(400).send({ msg: 'Could not delete product', status: 400, success: false });
|
||||
}
|
||||
|
||||
res.send({ msg: 'Product deleted', status: 200, success: true, data: id });
|
||||
return res.send({ msg: 'Product deleted', status: 200, success: true, data: id });
|
||||
});
|
||||
|
||||
// =========
|
||||
|
||||
Reference in New Issue
Block a user