How to add email to my pod?

i read the tutorial https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/getting-started-part2/
,try to add email to my pod,but addStringNoLocale not useful to add email
has an error when i run

Uncaught (in promise) TypeError: Cannot read property 'value' of undefined
    at internal_toIriString (interfaces.internal.mjs:27)
    at internal_isValidUrl (datatypes.mjs:300)
    at addTerm (add.mjs:219)
    at addLiteral (add.mjs:201)
    at addLiteralOfType (add.mjs:229)
    at addStringNoLocale (add.mjs:167)
    at createCard (index.js:99)
    at HTMLButtonElement.buttonCreatecard.onclick (index.js:193)
internal_toIriString @ interfaces.internal.mjs:27
internal_isValidUrl @ datatypes.mjs:300
addTerm @ add.mjs:219
addLiteral @ add.mjs:201
addLiteralOfType @ add.mjs:229
addStringNoLocale @ add.mjs:167
createCard @ index.js:99
buttonCreatecard.onclick @ index.js:193

Are there any way to add the email to my pod?

async function createCard(){
    labelCreatecardStatus.textContent = "";
    const podUrl1 = document.getElementById("PodURL1").value;
    //add a link to this resource in my profile that applications can follow.
    const cardListUrl = `${podUrl1}/getting-started/cardList/myCard`;
    // Add email to the Dataset
    let cardemail = document.getElementById("cardemail").value;
   
    let myCardList  = createSolidDataset();
    let cardinfo = createThing({name:"CardID"});

    cardinfo = addStringNoLocale(cardinfo, SCHEMA_INRUPT_EXT.email, cardemail);
1 Like

Hi @wenjingli-qa, it looks like @inrupt/vocab-common-rdf does not include a constant for schema:email.

An alternative is to just use the URL directly, e.g. like this:

    cardinfo = addStringNoLocale(cardinfo, "http://schema.org/email", cardemail);

Another alternative is to import it from a package that does include all Schema.org terms, such as rdf-namespaces:

import { schema } from "rdf-namespaces";

// ...later
    cardinfo = addStringNoLocale(cardinfo, schema.email, cardemail);

I’m currently not sure if there’s a way to request additional constants to be added to @inrupt/vocab-common-rdf, but I’ll ask around.

Hi @wenjingli-qa - yes, @inrupt/vocab-common-rdf very deliberately does not include all the terms from Schema.org, because there are over 2,500 of them now!
So Inrupt’s common RDF vocab module cherry-picks terms from Schema.org, terms that we think are ‘the most useful Terms to most people’, and we plan to add to that cherry-picked list based on our own usage, and of course, general feedback - i.e., precisely the kind of feedback you’re providing here :slight_smile: !
That’s why the classname we expose in our module is SCHEMA_INRUPT_EXT, and not just SCHEMA, i.e., it’s Inrupt’s interpretation of the most useful terms, and it also extends Schema.org in that it also provides various translations (e.g., into French, German, Italian, etc.) for the labels and comments of the terms we’ve cherry-picked (a contribution we’ve already discussed with the Schema.org folks, and they’ll be happy to accept).
So I’ve already added schema:email to our cherry-picked list, and I can do a new release later - but before I do, are there any other terms from Schema.org that you might like added…?

Oh, and actually, @inrupt/vocab-common-rdf already provides a convenient workaround for your use-case that you can use straightaway - rather than hard-coding the full string, you can use SCHEMA_INRUPT_EXT.NS("email"). At least that way to don’t have to hard-code the namespace part of the IRI (although you do have the nasty hard-coded string for the email part - hence this being a workaround!).

Hi @wenjingli-qa - just to update you, and hopefully close this out, I released an update to @inrupt/vocab-common-rdf (to version 0.7.4) that now includes Schema.org’s email term. Thanks again for the feedback!

Thank you so much! It has been worked after updating @inrupt/vocab-common-rdf to latest version. thx for your help~

1 Like