JavaScript, make a POST with JSON data with fetch() - Stack Overflow

PHOTO EMBED

Tue Jul 26 2022 10:40:34 GMT+0000 (Coordinated Universal Time)

Saved by @pycajiqutu #javascript

(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);
})();
content_copyCOPY

https://stackoverflow.com/questions/29775797/javascript-make-a-post-with-json-data-with-fetch