Modifying an element in the list
Here we show how to modify an element of the list, keeping this modification in the database. A PUT
type request will be used for this.
Using Axios with a PUT type request (client side)
The axios.put("/list", options)
method is used to perform a PUT
type request to the server. We transmit to the server in the options
parameter the new text of the modified element and its identifier in the database. The identifier and the new text will allow the item to be updated on the server:
Modifying an element, client side (global-app.js file)
import Element from "./element.js"; const GlobalApp = { data() { return { elements : [] // array of object { text, _id } // (_id = document id in MongoDB) } ...