import { getSolidDataset, getStringNoLocale, getThingAll, getUrl } from '@inrupt/solid-client'; import { FOAF, VCARD } from '@inrupt/vocab-common-rdf'; export const fetchPod: typeof fetch = async (resource: URL | RequestInfo) => fetch(`/solid/fetch?resource=${encodeURIComponent(resource.toString())}`); export const getProfile = async (webId: string) => { const dataset = await getSolidDataset(webId, { fetch: fetchPod }); const subjects = getThingAll(dataset); console.log({ webId, subjects }); const findValue = (predicate: string) => subjects .map((subject) => getStringNoLocale(subject, predicate) || getUrl(subject, predicate)) ?.filter((i) => !!i)[0]; return { name: findValue(FOAF.name), organization: findValue(VCARD.organization_name), image: findValue(VCARD.hasPhoto) }; };