This commit is contained in:
Philippe Torrel
2026-07-23 14:56:15 +02:00
parent 702443e90e
commit c118892017
7 changed files with 199 additions and 13 deletions

View File

@@ -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 });
});
// =========