'use strict'; const BASE_URL = 'http://150.145.56.132'; const RES_ENDPOINT = '/resources/'; /** * @todo Query report links to determine resource type? * @param {int} max Max number of resources to list * (randomly selected) * * @returns {Array} An array with selected resource links */ export async function fetchResourceList(max = 20) { // TODO Errors!! let req = new Request(`${BASE_URL}${RES_ENDPOINT}`); const res = await fetch(req).catch(); const list = await res.json(); return list['ldp:contains'].slice(100, max + 100) .map(e => e.replace( 'http://localhost:8000/resources', `${BASE_URL}/report`)); } /** * Create links list * @param {string[]} links The fetched resource links * @param {string} id The ID of the UL element * */ export function createLinks(links, id) { for (const link of links) { const item = document.createElement('li'); item.innerHTML = `${link}`; document.querySelector(`#${id}`).appendChild(item); } } /** * Process JSON report... */ /** * Query report links to determine * resource instance type... */