I have been encountering difficulties while attempting to retrieve data from a Stardog triple store into Angular. Despite successfully accessing the service using curl with matching headers and parameters, I am unable to replicate this functionality within my Angular application. Even after trying variations like omitting parameters and manually entering the full URL ('localhost:5820/myDB/query?reasoning=false&query=SELECT * WHERE {?s ?p ?o}'), I haven't had any success.
private _queryUrl = 'http://localhost:5820/myDB/query';
constructor(private _http: Http) {}
getData() {
let username : string = 'admin';
let password : string = 'admin';
let headers = new Headers();
headers.append('Authorization', "Basic " + btoa(username + ":" + password));
headers.append('Content-Type', 'application/rdf+xml');
headers.append('Accept', 'application/sparql-results+json');
let params = new URLSearchParams();
params.set('reasoning', 'false');
params.set('query', 'SELECT * WHERE {?s ?p ?o}');
let options = new RequestOptions({ headers: headers, search: params });
return this._http
.get(this._queryUrl, options)
.map((res: Response) => res.json());
}