From b705edc5d7e3eea427ace22b6cd3718f1ff01de1 Mon Sep 17 00:00:00 2001 From: "henriette.rebnor" Date: Tue, 3 Sep 2024 23:39:39 +0200 Subject: [PATCH] fix issue with cors --- rdfox/boundaries.rdfox | 2 +- rdfox/endpoint.params | 2 ++ www/script.js | 21 ++++++++------------- 3 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 rdfox/endpoint.params diff --git a/rdfox/boundaries.rdfox b/rdfox/boundaries.rdfox index a8bb660..cd0a161 100644 --- a/rdfox/boundaries.rdfox +++ b/rdfox/boundaries.rdfox @@ -19,5 +19,5 @@ importaxioms asset:axioms import > schema:shacl ../shacl/imf-dexpi.shacl.ttl commitproc set commit-procedure.sparql -set access-control-allow-origin * +set endpoint.access-control-allow-origin * endpoint start diff --git a/rdfox/endpoint.params b/rdfox/endpoint.params new file mode 100644 index 0000000..f97de1e --- /dev/null +++ b/rdfox/endpoint.params @@ -0,0 +1,2 @@ +#Enable cors +access-control-allow-origin * \ No newline at end of file diff --git a/www/script.js b/www/script.js index 0414f07..5a1969d 100644 --- a/www/script.js +++ b/www/script.js @@ -4,9 +4,7 @@ document.addEventListener("keyup", (event) => { if (event.key === "Enter") { console.log("enter pressed") let query = 'SELECT ?node WHERE{?node a data:insideBoundary .}' - var result = queryTripleStore(query) - console.log(result.payload) - console.log("tried to log") + result = queryTripleStore(query) } }); @@ -94,14 +92,11 @@ function queryTripleStore(sparql) { fetch(`http://localhost:12110/datastores/boundaries/sparql?query=${encoded}`, { method: 'GET', }) - .then(response => { - console.log("trying to log reposnse") - console.log(response.text())}) - .then(data => { - console.log("trying to log response") - console.log(data); - }) - .catch(error => { - console.error('Error:', error); - }); + .then(response => response.text()) + .then(data => { + console.log(data); + }) + .catch(error => { + console.error('Error:', error); + }); } \ No newline at end of file