Skip to content

Commit e45729d

Browse files
authored
Update cors.html
1 parent 31b93f5 commit e45729d

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

assets/cors.html

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
<!doctype html>
2-
<html>
3-
<body>
4-
<pre id=result>running...</pre>
5-
<script>
6-
const url = "https://backend-test.uitpas.be/api/search/organiser";
7-
const body = {"from":0,"size":500,"query":{"query_string":{"query":"pointOfSale: true","fields":["address.zipcode","address.city","name"]}},"sort":{"name.raw":"asc"}};
1+
<!DOCTYPE html>
2+
<meta charset="UTF-8">
3+
<title>CORS PoC</title>
84

9-
fetch(url, {
10-
method: "POST",
11-
credentials: "include", // try with and without depending on endpoint auth
12-
headers: { "Content-Type": "application/json" },
13-
body: JSON.stringify(body)
5+
<script>
6+
fetch("https://backend-test.uitpas.be/api/search/organiser", {
7+
method: 'POST',
8+
headers: {
9+
'Content-Type': 'application/json'
10+
},
11+
body: JSON.stringify({
12+
from: 0,
13+
size: 500,
14+
query: {
15+
query_string: {
16+
query: "pointOfSale: true",
17+
fields: ["address.zipcode", "address.city", "name"]
18+
}
19+
},
20+
sort: {"name.raw": "asc"}
21+
})
22+
})
23+
.then(response => response.text())
24+
.then(data => {
25+
console.log("Response:", data);
1426
})
15-
.then(r => r.text().then(t => ({status: r.status, headers: [...r.headers], body: t})))
16-
.then(obj => document.getElementById("result").textContent = JSON.stringify(obj, null, 2))
17-
.catch(err => document.getElementById("result").textContent = "error: " + err);
27+
.catch(err => {
28+
console.error("Request failed:", err);
29+
});
1830
</script>
19-
</body>
20-
</html>

0 commit comments

Comments
 (0)