I’ve just had a long look around and searched but to no avail. The browser won, so can anyone help by showing me the code that takes a SAFE URI and uses it to retrieve data from the network.
I’m looking to see how it works with both a regular public name URI, and one based on a WebID.
Thanks!
1 Like
I believe this is what you’re looking for
/**
* @private
* Helper function to lookup a given `safe://`-URL in accordance with the
* public name resolution and find the requested network resource.
*
* @param {String} url the url you want to fetch
* @param {WebFetchOptions} [options=null] additional options
* @returns {Promise<Object>} the object with body of content and headers
*/
async function webFetch(url, options) {
const { content, resourceType, parsedPath, mimeType } = await fetchHelper.call(this, url);
if (resourceType === DATA_TYPE_RDF) {
const emulation = content.emulateAs(resourceType);
await emulation.nowOrWhenFetched();
// TODO: support qvalue in the Accept header with multile mime types and weights
const reqMimeType = (options && options.accept) ? options.accept : 'text/turtle';
const serialisedRdf = await emulation.serialise(reqMimeType);
const response = {
4 Likes
Spot on Lionel, thanks very much. I appreciate your speed and accuracy!
1 Like
This topic was automatically closed after 60 days. New replies are no longer allowed.