Skip to content

Instantly share code, notes, and snippets.

@Uvacoder
Forked from whoisryosuke/fetch-post-request.js
Created October 18, 2022 16:10
Show Gist options
  • Select an option

  • Save Uvacoder/c092e3355246119a4f071a26b43f0a77 to your computer and use it in GitHub Desktop.

Select an option

Save Uvacoder/c092e3355246119a4f071a26b43f0a77 to your computer and use it in GitHub Desktop.
JS - Fetch POST request as async function
(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);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment