ali1k / ld-r

Linked Data Reactor (LD-R)
http://ld-r.org
Other
128 stars 30 forks source link

reference to the sparql endpoint for a dataset (Dynamic Configuration) #89

Closed ccolonna closed 3 years ago

ccolonna commented 3 years ago

Hello!

suppose i navigate a dataset, is there a way to get a reference to the sparql endpoint where the dataset is hosted, in case i'm connected via dynamic configuration?

I found a getDynamicEndpointParameters in ./utils/helpers but i cannot figured it out how to use it as the function accepts a callback and doesn't return anything.

what i need would be something like: const sparqlEndpointConfig = getSparqlEndpoint(datasetURI)

I wonder if you could suggest some ideas :)

Thank you very much for your help!

ali1k commented 3 years ago

Hi @Christian-Nja sorry for my late replies!

getDynamicEndpointParameters is the right function to use. And indeed it is a async function for which you would need to use a callback function like:

getDynamicEndpointParameters(user, datasetURI, (endpointParameters)=> {
       graphName = endpointParameters.graphName;          
      //your code    
});

If you like to run this in a synchronous way, you need to write some wrappers based on async and await. Then you would be able to run something like:

const sparqlEndpointConfig = await getDynamicEndpointParameters(datasetURI);

see https://javascript.info/async-await for some tutorials...

ccolonna commented 3 years ago

Thank you very much @ali1k i managed to do this!