Update data using a PUT request in JavaScript

preview_player
Показать описание
To use a PUT request using JavaScript, specify the data that should be updated.

In our example, we get specific and identify the article post we'd like to update by said post's id value.

This id is referenced in the url endpoint. Accordingly, this enables us to point to the data we want and change it via a PUT request that "carries" a payload of new data.

If you guys have questions about what's an API, look at this video,

If you have questions about what a request method is view this video,

The following are videos of how to implement specific methods,

Best,

Fido

-----------------------------------------------------------------------------------------
Follow me on instagram 📸 : @selftaughthustle
*/
Рекомендации по теме
Комментарии
Автор

You should've added headers: {
'Content-Type': 'application/json'
},
to your options object. If you don't and send PUT request to the actual server, it will delete the "posts/4" resource entirely leaving only ID.

Pavel-wjgy
Автор

Awesome tutorial! So many good qualities in one place: very easy to follow, explains just what it needs in to (but in depth), also doesn't add any extra unnecessary bs. Thx for your work Sir! Whata, just 700 subs, you deserve way more!

MaxSharpy
Автор

if there is an json element in the server consists of 20 item for example and i want to change one value only without writting the whole element again, how to do it...

youssefosama
Автор

I like this video, please make some playlists for your videos and collect it to make it easy to search and brows videos in ur channel

mohammad_alhalla
Автор

which theme you're using on your vscode?

philcoding