Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Latest commit

 

History

History
42 lines (34 loc) · 669 Bytes

javascript.md

File metadata and controls

42 lines (34 loc) · 669 Bytes

JavaScript Snippets

  • Post Request - pr
fetch("http://example.com/api/endpoint/", {
method: "post",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},

//make sure to serialize your JSON body
body: JSON.stringify({
name: myName,
password: myPassword
})
})

  • Promises Post Request - ppr
fetch("http://example.com/api/endpoint/", {
method: "post",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},

//make sure to serialize your JSON body
body: JSON.stringify({
name: myName,
password: myPassword
})
})
.then( (response) => {
//do something awesome that makes the world a better place
});