Updating Data
Learn how to update the server data.
We'll cover the following
The setItem
method can also be used to update the data. To demonstrate this, we will add a new section to the project to toggle the posts featured
property. This will change the background color of the post to highlight it.
The update process
The process is similar to adding a new post. The process is explained below:
Create a form to add the post ID to update and a checkbox to toggle the
featured
setting.Call a function to trigger a PUT request.
Retrieve our existing posts from the store.
Update the
featured
property on the required post.Update the storage and return the posts.
The update form
We begin by adding a form to the admin.vue
file to toggle the featured
property on a selected post:
Get hands-on with 1400+ tech skills courses.