Created
February 18, 2022 19:50
-
-
Save joaobispo2077/386473d38f53b4a391ffe263ada30193 to your computer and use it in GitHub Desktop.
request with curl and fetch api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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