Endpoint to edit a note
We’ll have to edit note. We’ll use PUT method as we’ll use it to send data to server to modify existing data.
- Go to workspace page and select “new endpoint”.
- Name the endpoint as “editNotes” and url as “/notes/edit/”.
- We’ll use PUT method here as we want to send data and retrieve existing data.
- Select “save” to create your endpoint.
- Now we’ll use fetch One block to get the particular note to be edited.
- Drag and drop a “database fetch one” block and select “note” table in table name and give variable name as note.
- Add condition for id to fetch the note. Use dot operator to extract id from the data variable for the id field. {{data.id}}
- Drag and drop a database update block to update the note.
- Name variable as note (same as fetch one block variable) and add data to name and body field by extracting appropriate data from data variable and save the block.
- Drag and drop a response block and select 200 status code to send a success response and save the response block.
- Deploy the project
# Test it out
- Once the project is launched in browser, try editing the a note using edit link in note entry.
- Next we’ll create endpoint to edit note that we created.....
# Next steps
Now lets make an endpoint to delete notes. See Build endpoint to delete notes