#6 DELETE and PUT
Last updated
Was this helpful?
Last updated
Was this helpful?
You've already implemented adding and getting data from database. Based on what we covered today you may now want to start deleting items. I bet you already know which method to use. π To call DELETE, you have to specify which item you want to delete. You must choose the most unique part of the item: _id
. The server accepts calls to DELETE an item and requires a path to items/:id
and no body. :id
defines name of the argument, sometimes you will have several of those. In this case we have only one.
Try to do it yourself! πͺ
Does your code look like the snippet below?
Marking an item as completed is editing the item. Try to edit the item in the database by implementing proper HTTP call. The server accepts calls to the path items/:id
, method PUT, and body with adequate data.
Remember to retrieve data from database upon success.
You may see how your code should look like in .
Now you may clean the code:
get rid of unused elements
define http://localhost:3000/
as a class property
maybe even define server url inside environment.ts
and environment.prod.ts
If you will have any problems, please contact your mentor π
Do what you think will make code cleaner, more reusable, get familiar with and principles.
As you might have noticed in final code there is different button which is using . Your task is to use Angular Material elements in the app. You may change every element.