Question about retrieving data


#1

Firstly, please forgive the stupid questions, I have limited programming experience.

I’m messing about with Solid and I’ve created a POD. I haven’t been able to do a lot with it apart from enter my name, email and add a profile photo. Anyway, i have managed to login to my website and retrieve/display my name using the “profile viewer tutorial”.

So to get the profile name i used…
const fullName = store.any($rdf.sym(person), FOAF(‘name’));

I would like to also retrieve other info but i’m not sure how to do it. i had a look at the Solid HTTPS REST API Spec, but i couldn’t make sense of any of it.

I have tried things like…
const email = store.any($rdf.sym(person), FOAF(‘email’)); console.log(email)

…but to no avail. Can someone please inform me of how to fetch other profile data such as email, profile pic, etc. using JS?


Authorization Code Flow
#2

Have you seen the thread Some basic resources for newcomers? I think it’s quite useful for a lot of people coming into the Solid technologies :slight_smile:

Also https://solid.inrupt.com/docs/getting-started is a good place to start I think :slight_smile:


#3

I think you got it right. What happens? You write “to no avail” - but what does that imply? I assume you get no errors - just an empty value since you do not have an e-mail associated with your profile.

Got to your profile card at (for instance) https://YOURNAME.solid.community/profile/card#me, fold-out your card (click the triangle), hover the mouse over your name and click on the </> icon that appears.

Now you can see the actual RDF source from your card and what values you have and their corresponding predicates (like FOAF(‘email’)).


#4

Thanks for the reply’s. I managed to get it to load some stuff, e.g.

const VCARD = new $rdf.Namespace('http://www.w3.org/2006/vcard/ns#');
let picture = store.any(me, VCARD('hasPhoto'));
console.log(picture.value);
let role = store.any(me, VCARD('role'));
console.log(role.value);
let note = store.any(me, VCARD('note'));
console.log(note.value);

I wasn’t able to load the email address but that was due to an issue in the pod, e.g…
Outline.expand: Unable to fetch mailto:me@me.com: Failed to load

Anyway, it’s a start :wink: Next i need to figure out how to write to the POD (maybe tomorrow)


#5

Maybe you can find my little “Object to RDF mapper” at https://github.com/JornWildt/SolidRC/blob/master/wwwroot/js/ORDFMapper.js useful for some research. It allows you to define a mapping between simple JavaScript objects and linked data resources - and uses RDFLIB to access the POD.


#6

And this thread covers my discoverings on the subject: My first app - adding resources?

I’ve managed to use RDFLIB without any low level HTTP work. Add, Query, Delete works like this:

Adding resource at URL X:

  • Add statements <X, some-predicate, some-value, X> for each property of the resource. Use store.add(X,p,v,X) to save the statements locally;
  • PUT the new statements onto the web: Use fetcher.putBack(X);

Reading list of resources:

  • Load all resources into local store using “globbing”. Use fetcher.load('baseUrl/*")
  • Extract all the found data from the local store. Use store.match(…)

Remove a single resource at url X:

  • Remove the resource from the web. Use fetcher.delete(X).
  • Remove local knowledge of the resource: Use store.removeDocument(X).
  • Remove all local statements: Use store.removeMatches(X);

#7

Oh, and beware that the web-oriented operations in the fetcher are all async using promises.

It took me awhile to figure out why my “refresh list” operation did not include a newly added resource. That was because the “put” operation executed asynchronously and did not complete before the refresh list called the server for a an update.

Be careful to add await .then() and .catch() to the right places in your code.