send post request code example

Example 1: javascript send post request

let data = {element: "barium"};

fetch("/post/data/here", {
  method: "POST", 
  body: JSON.stringify(data)
}).then(res => {
  console.log("Request complete! response:", res);
});


// If you are as lazy as me (or just prefer a shortcut/helper):

window.post = function(url, data) {
  return fetch(url, {method: "POST", body: JSON.stringify(data)});
}

// ...

post("post/data/here", {element: "osmium"});

Example 2: curl post request

curl -d "user=user1&pass=abcd" -X POST https://example.com/login

Example 3: send post request postman

{
 "title" : "test title",
 "singer" : "some singer"
}