diff --git a/backend/app.js b/backend/app.js
index 542816d..50ac325 100644
--- a/backend/app.js
+++ b/backend/app.js
@@ -229,6 +229,19 @@ app.post('/api/item', (req, res, next) => {
}
});
+app.delete('/api/item/:id', (req, res, next) => {
+ console.log('delete endpoint', req.params.id);
+ itemmodel.findByIdAndDelete(req.params.id, function (err, docs) {
+ if (err) {
+ console.log(err);
+ } else {
+ res.status(200).json({
+ message: 'Item deleted'
+ });
+ }
+ });
+});
+
app.get('/api/price', (req, res, next) => {
console.log('Get /api/price');
CoinGeckoClient.simple.price({
diff --git a/src/app/items/item-list/item-list.component.html b/src/app/items/item-list/item-list.component.html
index 41d79ed..905af38 100644
--- a/src/app/items/item-list/item-list.component.html
+++ b/src/app/items/item-list/item-list.component.html
@@ -1,4 +1,3 @@
-
Items!
0">
diff --git a/src/app/items/item-list/item-list.component.ts b/src/app/items/item-list/item-list.component.ts
index 869983c..2320f35 100644
--- a/src/app/items/item-list/item-list.component.ts
+++ b/src/app/items/item-list/item-list.component.ts
@@ -110,6 +110,7 @@ export class ItemListComponent implements OnInit{
dialogRef.afterClosed().subscribe((val) => {
if (val != null) {
console.log('Deleting', val);
+ this.itemService.deleteItem(val);
}
this.itemService.getItems(this.owner.address);
});
diff --git a/src/app/items/items.service.ts b/src/app/items/items.service.ts
index f1e3ee8..744cdea 100644
--- a/src/app/items/items.service.ts
+++ b/src/app/items/items.service.ts
@@ -39,4 +39,14 @@ export class ItemService{
return obs;
}
+
+ deleteItem(id: string) {
+ let obs = this.http.delete<{message: string}>('http://localhost:3000/api/item/'+id);
+
+ obs.subscribe((ItemResponse) => {
+ console.log('Item deleted');
+ });
+
+ return obs;
+ }
}