js fetch 'post' json
//Obj of data to send in future like a dummyDb
const data = { username: 'example' };
//POST request with body equal on data in JSON format
fetch('https://example.com/profile', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then((response) => response.json())
//Then with the data from the response in JSON...
.then((data) => {
console.log('Success:', data);
})
//Then with the error genereted...
.catch((error) => {
console.error('Error:', error);
});
// Yeah
Also in JavaScript:
- angular redirect to external url
- javascript getdate
- string repeat javascript
- useBootstrapPrefixhttp://localhost:8000/static/js/bundle.js:15261:75
- uninstall node js from mac
- node js require file in parent directory
- discord.js bad word filter
- jsx full form
- javascript title string
- push object to json array
- fizzbuzz javascript
- javascript remover acentos
- syntax for srcset in react
- perform a function on each element of array javascript
- loop through json array python
- sjson.Set query
- moment for react
- open pdf in browser javascript
- ORDS GET json case sensitive data keys
- how to delete cookie node js
- difference between type and method in ajax
- "rbac" react redux navigation bar
- javascript convert timezone name to abbreviation
- BottomNavigationBar rebuilds Page on change of tab