Skip to content

Instantly share code, notes, and snippets.

@SuperCipher
Created March 30, 2021 12:07
Show Gist options
  • Save SuperCipher/366a69c8bc368145b2e4dfbbbd53a8d8 to your computer and use it in GitHub Desktop.
Save SuperCipher/366a69c8bc368145b2e4dfbbbd53a8d8 to your computer and use it in GitHub Desktop.
fetch real life example
function requestBid(eventID,requestSlpAddress) {
const url = AUCTION_BACKEND_URL;
const data = {
eventID: eventID,
bidderAddress: requestSlpAddress
};
const jsonData = JSON.stringify(data);
const params = {
headers: {
"content-type":"application/json; charset=UTF-8"
},
body: jsonData,
method: "POST"
};
fetch(url, params)
.then(data=>{return data.json()})
.then(res=>{console.log('RES', res)})
.catch(error=>console.log('ERROR', error));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment