Created
November 29, 2021 08:35
-
-
Save whoisryosuke/a9e0aa879549f8d5e1ef9235c7e82565 to your computer and use it in GitHub Desktop.
JS - Fetch POST request as async function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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