Answers for "javascript do http post request"

9

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"});
Posted by: Guest on March-04-2020
0

how to make post request in javascript for api call

const data = {
    'keyone': 'valueone',
    'keytwo': 'valuetwo'
};

$.post(url, data, function(data,status){
	console.log(data);
});
Posted by: Guest on June-30-2021

Code answers related to "javascript do http post request"

Code answers related to "Javascript"

Browse Popular Code Answers by Language