Created
May 11, 2020 14:20
-
-
Save pasqLisena/a7b792de98474ff9c13c6e47e366f58a to your computer and use it in GitHub Desktop.
GRLC SILKNOW example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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