fetch get api key content type json code example
Example: fetch api javascript
// This will fetch api.example.com/comments with a header and a body
fetch(`https://api.example.com/comments`, {
method: 'POST', //This could be any http method
headers: {
'Authorization': 'Basic SGVsbG8gdGhlcmUgOikgSGF2ZSBhIGdvb2QgZGF5IQ==',
'Content-Type': 'application/json',
},
body: JSON.stringify({
UID: 58,
Comment: "Fetch is really easy!",
}),
})
.then((response) => response.json)
.then((newComment) => {
// Do something magical with your newly posted comment :)
});