fetch-sparql-endpoint
Advanced tools
Comparing version 2.3.3 to 2.4.0
@@ -18,2 +18,3 @@ /// <reference types="node" /> | ||
readonly method: 'POST' | 'GET'; | ||
readonly additionalUrlParams: URLSearchParams; | ||
readonly fetchCb?: (input?: Request | string, init?: RequestInit) => Promise<Response>; | ||
@@ -100,2 +101,3 @@ readonly sparqlParsers: { | ||
method?: 'POST' | 'GET'; | ||
additionalUrlParams?: URLSearchParams; | ||
/** | ||
@@ -102,0 +104,0 @@ * A custom fetch function. |
@@ -22,2 +22,3 @@ "use strict"; | ||
this.method = args.method || 'POST'; | ||
this.additionalUrlParams = args.additionalUrlParams || new URLSearchParams(); | ||
this.fetchCb = args.fetch; | ||
@@ -149,3 +150,3 @@ this.sparqlJsonParser = new sparqljson_parse_1.SparqlJsonParser(args); | ||
async fetchRawStream(endpoint, query, acceptHeader) { | ||
const url = this.method === 'POST' ? endpoint : endpoint + '?query=' + encodeURIComponent(query); | ||
let url = this.method === 'POST' ? endpoint : endpoint + '?query=' + encodeURIComponent(query); | ||
// Initiate request | ||
@@ -159,4 +160,10 @@ const headers = new Headers(); | ||
body.set('query', query); | ||
this.additionalUrlParams.forEach((key, value) => { | ||
body.set(key, value); | ||
}); | ||
headers.append('Content-Length', body.toString().length.toString()); | ||
} | ||
else if (this.additionalUrlParams.toString() !== '') { | ||
url += `&${this.additionalUrlParams.toString()}`; | ||
} | ||
return this.handleFetchCall(url, { headers, method: this.method, body }); | ||
@@ -163,0 +170,0 @@ } |
{ | ||
"name": "fetch-sparql-endpoint", | ||
"version": "2.3.3", | ||
"version": "2.4.0", | ||
"description": "A simple, lightweight module to send queries to SPARQL endpoints and retrieve their results in a streaming fashion.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -43,6 +43,7 @@ # Fetch SPARQL Endpoint | ||
const myFetcher = new SparqlEndpointFetcher({ | ||
method: 'POST', // A custom HTTP method for issuing (non-update) queries, defaults to POST. Update queries are always issued via POST. | ||
fetch: fetch, // A custom fetch-API-supporting function | ||
dataFactory: DataFactory, // A custom RDFJS data factory | ||
prefixVariableQuestionMark: false // If variable names in bindings should be prefixed with '?', defaults to false | ||
method: 'POST', // A custom HTTP method for issuing (non-update) queries, defaults to POST. Update queries are always issued via POST. | ||
additionalUrlParams: new URLSearchParams({'infer': 'true', 'sameAs': 'false'}); // A set of additional parameters that well be added to fetchAsk, fetchBindings & fetchTriples requests | ||
fetch: fetch, // A custom fetch-API-supporting function | ||
dataFactory: DataFactory, // A custom RDFJS data factory | ||
prefixVariableQuestionMark: false // If variable names in bindings should be prefixed with '?', defaults to false | ||
}); | ||
@@ -49,0 +50,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37169
10
451
154