Makes a POST or PUT request using the Fetch API

PHOTO EMBED

Wed Sep 07 2022 17:46:53 GMT+0000 (Coordinated Universal Time)

Saved by @jimmywilliams #javascript

fetch('https://reqres.in/api/users', { // Endpoint is a test API
    method: "POST", // or "PUT"
    headers: {
        'Content-type': 'application/json'
    },
    body: JSON.stringify(
        { name: "Captain Anonymous"}
    )
});
content_copyCOPY

https://openjavascript.info/2022/01/03/using-fetch-to-make-get-post-put-and-delete-requests/