Created
March 15, 2021 21:46
-
-
Save asunar/2110e8a11760ff081fd0f3a8fc0343a0 to your computer and use it in GitHub Desktop.
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
<html> | |
<body> | |
<button type="submit" onclick="submit();">Submit</button> | |
</body> | |
<script> | |
function submit(){ | |
fetch("<api_url>", { | |
// Adding method type | |
method: "POST", | |
// Adding body or contents to send | |
body: JSON.stringify({"message":" This is bad service"}), | |
// Adding headers to the request | |
headers: { | |
"Content-type": "application/json; charset=UTF-8" | |
} | |
}) | |
// Converting to JSON | |
.then(response => response.json()) | |
// Displaying results to console | |
.then(json => console.log(json)); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment