# Inrupt common vocabularies returning undefined

**URL:** <https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504>\
**Category:** Build a Solid App\
**Created:** [July 21, 2021, 9:53am UTC](https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504 "2021-07-21T09:53:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicomedia](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nicomedia](https://forum.solidproject.org/u/nicomedia)\
**Post date:** [July 21, 2021, 9:53am UTC](https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504/1 "2021-07-21T09:53:33Z")

</div>

I’m trying to build a Solid app that reads and writes data to pods, and I’m using the vocab-common-rdf and solid-client libraries to do that.  
The problem is that vocab-common-rdf returns undefined values for certain properties(for example VCARD.givenName), and there’s no documentation at all to understand what I’m doing wrong. If I try typing the URL in maunally([http://www.w3.org/2006/vcard/ns#given-name](http://www.w3.org/2006/vcard/ns#given-name)), I get an invalid URL error.

---

<div class="post-metadata">

**Author:** ![pmcb55](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/pmcb55/32/1256_2.png) [@pmcb55](https://forum.solidproject.org/u/pmcb55)\
**Post date:** [July 21, 2021, 9:19pm UTC](https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504/2 "2021-07-21T21:19:45Z")

</div>

Hi @nicomedia,

So yeah, I think the problem is that the term in the vCard RDF vocabulary has a ‘minus-sign’ (or hyphen) in it’s name (i.e., ‘given-name’), and of course that character is not valid in a variable or object property name in JavaScript, which is why our generator converts it to an underscore instead.  
So if you try `VCARD.given_name` (with an underscore instead of a hyphen) it should work fine for you.  
Thanks for the feedback on the lack of documentation to highlight this general issue though - we’ll look into fixing that (although if you’re using a modern IDE, then typing just `VCARD.give` should have prompted you with the code completion option of `VCARD.given_name`) 🙂 !

BTW, I don’t know what you mean by “typing the URL in maunally (sic)” - can you show a quick code-snippet of what you were trying exactly (as the string value for the term you provided is indeed correct)?

---

<div class="post-metadata">

**Author:** ![nicomedia](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nicomedia](https://forum.solidproject.org/u/nicomedia)\
**Post date:** [July 22, 2021, 10:48am UTC](https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504/3 "2021-07-22T10:48:53Z")

</div>

> [@pmcb55](#):
>
> I don’t know what you mean by “typing the URL in maunally (sic)”

Hi, I mean using a string with the URL instead of the convenience object, so for example instead of typing this:

```auto
let something = getStringNoLocale(profile, VCARD.given_name);

```

I use this:

```auto
let something = getStringNoLocale(profile, "http://www.w3.org/2006/vcard/ns#given-name");

```

I solved the problem by typing the URL out, it probably was a cache problem with the browser, but for some fields, for example the uid field in vCards, it still won’t work, so for now I’m stuck using URLs.  
I use VS code and it’s not giving me suggestions, should it?

---

<div class="post-metadata">

**Author:** ![pmcb55](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/pmcb55/32/1256_2.png) [@pmcb55](https://forum.solidproject.org/u/pmcb55)\
**Post date:** [July 22, 2021, 4:51pm UTC](https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504/4 "2021-07-22T16:51:08Z")

</div>

Hi @nicomedia,

So firstly, yeah, VS Code indeed isn’t picking up code completion suggestions for terms in a vocab (we tend to use IntelliJ, and it works fine there, so we never noticed this problem!). We’ve a fix for that already - so it’ll be in the next release of the bundled vocab artifacts.

But basically the names of all constants in the vocab classes that we generate will always match precisely the term names in the original RDF, _ **except** _ of course if the RDF term name happens to be illegal as a variable name in the programming language you’re working in. So for example, in Java or JavaScript, all hyphens that appear in a vocab term name will be converted to underscores to make them valid variable names. Terms that are default keywords in the language (like ‘const’, of ‘if’, or ‘class’, or ‘export’ in JavaScript) will have an underscore appended to the variable name (so, they’ll become ‘const\_’, ‘if\_’, ‘class\_’ and ‘export\_’ respectively).

So secondly, we’re actively updating our documentation to explain these issues - so hopefully these things won’t trip people up in the future.

As for the ‘uid field’ in vCard, do you mean ‘hasUID’? `VCARD.hasUID` works fine (i.e., there is no ‘uid’ term in the vCard vocabulary, that I can see anyways. If you do really mean ‘uid’, can you link to a reference (or even just a screenshot)?)

So I’d generally only use a term’s full IRI as a string as a last resort. Our generated vocab classes do include a convenience function to at least provide you with the vocabulary namespace part (called `NS()`), so your example could have been shortened to:

```auto
let something = getStringNoLocale(profile, VCARD.NS("given-name"));

```

This makes your code more readable, but also, it can be handy if, for instance, a new term is added to an existing vocabulary, but we haven’t published updated versions of our generated vocab bundles yet. So if vCard added a new term for `twitterHandle` tomorrow, you could use that new term in your code today by simply using:

```auto
let something = getStringNoLocale(profile, VCARD.NS("twitterHandle"));

```

Hopefully that clarifies everything for you - and thanks so much again for the extremely helpful feedback.

Cheers,  
Pat.

---

<div class="post-metadata">

**Author:** ![kay-kim](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/kay-kim/32/2860_2.png) [@kay-kim](https://forum.solidproject.org/u/kay-kim)\
**Post date:** [July 26, 2021, 5:13pm UTC](https://forum.solidproject.org/t/inrupt-common-vocabularies-returning-undefined/4504/5 "2021-07-26T17:13:52Z")

</div>

Hey all – as an FYI – the docs have now been updated to explain the naming scheme.

[https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/use-vocabularies/#convenience-object-naming-scheme](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/use-vocabularies/#convenience-object-naming-scheme)

As Pat mentioned, the next release of the bundled vocab artifacts should have the code-completion, so that people don’t have to look at the dreaded documentation 😄
