umami/test.html
2024-01-17 09:33:18 +01:00

28 lines
No EOL
1.5 KiB
HTML

<html>
<script>
async function postData(url = "", data = {}) {
// Default options are marked with *
const response = await fetch(url, {
method: "GET", // *GET, POST, PUT, DELETE, etc.
mode: "cors", // no-cors, *cors, same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json",
'Access-Control-Allow-Origin': '*',
"Authorization":"Bearer 6QEzcKYfrgQAemg1Z5e9oGwbGzPy2OAV3UH2N5IQF0Z7MwIhqtWTTCBCnQQcuFQEUJa3lXfkwD8G/SbFPKklcfDfbszJqIdxeDPwWbPY0ogSGebEVdz9lZBb0dQmgSEOEpVgG4ux+Qt18PzYX6fLEbCMqO6wR7A3Z5StDDct6s35kEQj1fW7ln7HXkgp22MJx3hqNgJ/01D6avAA+dv2A8uG3j64zaqmlK0S4tntczXbXGfR8u9x3qmMm74o+JMcfSnRiNMVA0zbDOVHx4w/GKzqfYs3HASY+qN7upwYIYPSk4AAY2o24cfVn5ZPGqyRuF91RXechyVe98n4tBll1edQ+XkqrAXQ6w==",
"Orgin":"localhost"
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect: "follow", // manual, *follow, error
referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
//body: JSON.stringify(data), // body data type must match "Content-Type" header
});
return response.json(); // parses JSON response into native JavaScript objects
}
postData("http://localhost:8080/api/websites/", { answer: 42 }).then((data) => {
console.log(data); // JSON data parsed by `data.json()` call
});
</script>
</htm>