Hi @glensimister ,
Welcome back to your exploration…
First, “undefined” is not an error in that case, it’s often because the data is not there
Don’t be affraid with RDF & linked Data, it 's all about things and links between those things…
i’m using ldflex largely for my projects as you can see
agora/config-get-view.js at dd67463799c22ce1dbfa01495807659796f94f13 · scenaristeur/agora · GitHub .
but i think email is a little particular as it can have many values and can not be directly accessed on a POD.
First , ldflex does not only have foaf, here are all the vocabs I’ve found in the @solid/context of the package.json
context/context.json at master · solid/context · GitHub
I’ve never used email, but i just created emails on a test POD to try
TO get email you can test that POD https://spoggy-test.solid.community/profile/card#me
When you put email through the databrowser (see the “</>” icon to look at the data ) , the data is stored like that
...
:id1587748083850 a n:Home; n:value <mailto:test@solid.test>.
:id1587748108886 a n:Dom; n:value <mailto:swing@pop.boo>.
:id1587748123046 n:value <mailto:hello@me.cool>.
:id1587748147974 a n:Dom; n:value <tel:0123456789>.
:id1587748173361 a n:Home; n:value <tel:9876543210>.
:id1587748195447
n:country-name "My Contry";
n:locality "The town";
n:postal-code "12345";
n:region "Cool region";
n:street-address "00 my street".
:id1587748237533
n:country-name "Somewhere";
n:locality "UnderTheSea";
n:postal-code "888888";
n:region "Sea Under";
n:street-address "123 another street".
:me
a schem:Person, n0:Person;
n:fn "Spoggy-Test";
n:hasAddress :id1587748195447, :id1587748237533;
n:hasEmail :id1587748083850, :id1587748108886, :id1587748123046;
n:hasPhoto <highres_274291645%5B1%5D.jpeg>;
n:hasTelephone :id1587748147974, :id1587748173361;
n:note "what is the note";
n:organization-name "Smag0";
n:role "Tester";
...
Well now, How to retrieve that ?
The example on ldflex-query repo are pointing to @RubenVerborgh server and seems to be a little bit outdated or not really compatible with the Pod implementation.
For example to retrieve the name on a POD
solid.data['https://devolution.inrupt.net/profile/card#me'].name
that is a shortcut of foaf:name does not work on a pod as it search as you mentionned to foaf:name…
You must use solid.data['https://devolution.inrupt.net/profile/card#me'].vcard$fn
For the data on my pod :
solid.data['https://spoggy-test.solid.community/profile/card#me'].vcard$fn --> NAME
same with vcard$role, vcard$hasPhoto …and so on… a little issue with organization-name as it is a composed predicate…
so to get organization-name, you can replace vcard prefix by its uri, and something like
await solid.data['https://spoggy-test.solid.community/profile/card#me']["http://www.w3.org/2006/vcard/ns#organization-name"]
Well, now when you suppose there are many values (like emails), ldflex-query must be used with for await ...
as indicated on Ldflex/ldflex repo GitHub - LDflex/LDflex: A JavaScript DSL for querying Linked Data on the Web
So looking at the data structure stored on the POD,
you must find the objects of triples whose predicate is vcard$hasEmail
then when you got the objects of that triple, follow the predicate vcard$value.
I’ve not tried yet but something like the following must give you what you expected
for await (const emailId of solid.data['https://spoggy-test.solid.community/profile/card#me'].vcard$hasEmail)
console.log(`- ${emailId}`);
let email = await solid.data[${emailId }].vcard$value
console.log(`${email}`)
}
Be carefull of the backquotes that allow to wait for the promise to be complete
Is that ok for you ??
Last but not least, to help to build Solidarity Chat, i’ve put a layer on top of ldflex to retrieve the basic data of a pod (not email yet but could be ;-)) Here is the Shighl lib