Skip to content

Instantly share code, notes, and snippets.

@pasqLisena
Created May 11, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasqLisena/a7b792de98474ff9c13c6e47e366f58a to your computer and use it in GitHub Desktop.
Save pasqLisena/a7b792de98474ff9c13c6e47e366f58a to your computer and use it in GitHub Desktop.
GRLC SILKNOW example
// Uncomment next line if in NodeJS
// const fetch = require("node-fetch");
async function run() {
const results = []; // this can also be a global variable to update
let next = 'http://grlc.eurecom.fr/api-git/silknow/api/obj_map?endpoint=http%3A%2F%2Fdata.silknow.org%2Fsparql'
while (next) {
let response = await fetch(next);
let data = await response.json();
results.push(data)
let links = response.headers.get('link').split(',');
next = links.find(l => l.split('; ', 2)[1] == 'rel=next')
if (next) next = next.split(';', 2)[0].replace(/[<>]/g, '')
}
console.log(results)
return results;
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment