0

Whether cross-domain URIs are supported by rdflib.js?

The following URIs are not parsed by fetcher.nowOrWhenFetched:

Error:

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Code:

// source:https://github.com/solidos/solid-tutorial-rdflib.js#fetch-data-into-the-store-from-the-web
var uri = 'http://purl.obolibrary.org/obo/GENEPIO_0100155';
var store = $rdf.graph();
var timeout = 5000; // 5000 ms timeout
var fetcher = new $rdf.Fetcher(store, timeout);
fetcher.nowOrWhenFetched(uri, function(ok, body, response) {
    if (!ok) {
        console.log("Oops, something happened and couldn't fetch data " + body);
    } else if (response.onErrorWasCalled || response.status !== 200) {
        console.log('    Non-HTTP error reloading data! onErrorWasCalled=' + response.onErrorWasCalled + ' status: ' + response.status);
    } else {
        console.log("---data loaded---");

        var dataList = store.statements;
        for (var i=0; i<dataList.length;i++) {
            data = dataList[i]
            console.log(data)
        }

        console.log(store.namespaces);
    }
});

Best regards

chenkun
  • 45
  • 6

1 Answers1

0

Thanks.

This question has been resolved.

This is not a problem with rdflib.js, it is a problem with the server.

rdflib.js can parse IRI that which server allow CORS.

chenkun
  • 45
  • 6