-
-
Save Uvacoder/c092e3355246119a4f071a26b43f0a77 to your computer and use it in GitHub Desktop.
JS - Fetch POST request as async function
This file contains hidden or 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