vanilla fetch
<script>
console.log("Fetching https://exampleendpoint.argv.nl ...")
let response = await fetch("https://exampleendpoint.argv.nl", {
method: "POST",
body: "secret",
mode: "no-cors"
});
console.log("Status: ", response.status);
console.log("Response body: ", await response.text());
</script>
Output:
Secure CORS (basically just fetch, but cors, and secure)
<script src="https://cdn.jsdelivr.net/gh/FurriousFox/secure-cors/client/browser.js"></script>
<script>
fetch.config({
// the hostname or ip address running the secure-cors server
host: "exampleendpoint-secure-cors-server.argv.nl", // default: "127.0.0.1"
// the port the secure-cors server is running on
port: 443, // default: 11711
// whether to use wss:// or ws://
secure: true, // default: false
// whether to use DNS-over-HTTPS to resolve the hostname
doh: true, // default: false
});
console.log("Fetching https://exampleendpoint.argv.nl ...")
let response = await fetch("https://exampleendpoint.argv.nl", {
method: "POST",
body: "secret",
});
console.log("Status: ", response.status);
console.log("Response body: ", await response.text());
</script>
Output: