JSFiddle - React, Tailwind, and code Playground

JavaScript

const data = {
    title: 'Test title',
    body: 'Test body',
    userId: 42
}

const options = {
   method: 'POST',
   body: JSON.stringify(data),
   headers: {
       'Content-Type': 'application/json'
   }
};

fetch('https://jsonplaceholder.typicode.com/posts', options)
  .then(response => response.json())
  .then(json => console.log(json));