Skip to content

Instantly share code, notes, and snippets.

@joaobispo2077
Created February 18, 2022 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaobispo2077/386473d38f53b4a391ffe263ada30193 to your computer and use it in GitHub Desktop.
Save joaobispo2077/386473d38f53b4a391ffe263ada30193 to your computer and use it in GitHub Desktop.
request with curl and fetch api
// curl -d '' -H "Content-Type: application/json" -X POST url
(async () => {
try {
const rawResponse = await fetch('url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"timestampInicio": "2021-12-02 15:00:01",
"timestampFim": "2022-02-18 15:00:02",
"periodo": 0
});
});
const content = await rawResponse.json();
console.log(content);
} catch(error) {
console.log('@ERROR MESSAGE', error.message);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment