reactjs fetch send json code example
Example 1: fetch json post
(async () => {
const rawResponse = await fetch('https://httpbin.org/post', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({a: 1, b: 'Textual content'})
});
const content = await rawResponse.json();
console.log(content);
})();
Example 2: how to send axios delete to the backend reactjs
axios.delete(URL, {
headers: {
Authorization: authorizationToken
},
data: {
source: source
}
});