mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* fix: sparql-http-client should use built-in fetch * fix: disable tslint rule to accommodate for commonjs default export * revert default export * change export syntax
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import * as SparqlHttp from 'sparql-http-client';
|
|
|
|
const client = new SparqlHttp();
|
|
|
|
async function selectQuery() {
|
|
const response = await client.selectQuery('...', {
|
|
endpointUrl: 'http://example.com/endpoint',
|
|
});
|
|
|
|
const json = await response.json();
|
|
|
|
json.results.bindings.forEach(binding => {
|
|
console.log(`${binding.name.value} (${binding.name.termType})`);
|
|
});
|
|
}
|
|
|
|
async function askQuery() {
|
|
const response = await client.selectQuery('...', {
|
|
endpointUrl: 'http://example.com/endpoint',
|
|
});
|
|
|
|
const json = await response.json();
|
|
|
|
console.log(`The answer was ${json.boolean ? 'YES' : 'NO'}`);
|
|
}
|
|
|
|
async function constructQuery() {
|
|
const response = await client.constructQuery('...');
|
|
|
|
const json = await response.json();
|
|
|
|
console.log(`The answer was ${json.boolean ? 'YES' : 'NO'}`);
|
|
}
|
|
|
|
async function updateQuery() {
|
|
const response = await client.constructQuery('...', {
|
|
updateUrl: 'http://example.com/endpoint',
|
|
});
|
|
|
|
console.log(`The update ${response.ok ? 'succeeded' : 'faield'}`);
|
|
}
|