post method javascript code
const postData = async ( url = '', data = {})=>{
console.log(data);
const response = await fetch(url, {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
},
// Body data type must match "Content-Type" header
body: JSON.stringify(data),
});
try {
const newData = await response.json();
console.log(newData);
return newData;
}catch(error) {
console.log("error", error);
}
}
Also in JavaScript:
- denojs
- get field type file js and loop
- perl json response to list all the files in a directory
- return value from javascript function
- react native notifications error
- how to get a channelid discord.js
- Caesars Cipher javascript
- how to kill all node processes
- pass variable to regrex literal notation javascript
- flutter intl currency
- check if time is greater than javascript
- .includes javascript
- axios react post form data
- reverse string js
- json objects
- javascript set localstorage
- if statemnt shorthand js without else
- w3schools angular
- create json string c#
- console.log
- login condition if and else in router dom of react jsx
- how to remove a value from an array and return the new array in javascript
- the rest operator javascript
- blazor publish to chrome extension