Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Halfred can't parse Resources with null embeds #34

Open
gcaseres opened this issue Dec 10, 2018 · 2 comments
Open

Halfred can't parse Resources with null embeds #34

gcaseres opened this issue Dec 10, 2018 · 2 comments

Comments

@gcaseres
Copy link

Describe the bug
When trying to parse a Resource returned from a remote API with null embedded resources, halfred reports an error: TypeError: "embeddedElement is null"

It looks like the problem could be solved by adding an if statement in line 73 of parser.js. I can send the PR if needed.

I understand that having a null value for an embedded resource could not be the best option for a HAL API, but I couldn't find any good argument against having null values. (for example, some uninitialized embed that will be populated later).

To Reproduce
Just parsing a Resource with null values will raise the Error:

{
    "_embedded": {
        "embed": null
    }
}

Expected behavior
The parsing process should accomplish without errors.
When querying for the value of "embed", it should return null.

Node.js (please complete the following information):

  • OS: Ubuntu 18
  • Node.js version: 10.14.1
  • Halfred Version: 1.1.0
@samhiddenhand
Copy link

I ran into this issue too while using the Vimeo VHX/OTT API

@samhiddenhand
Copy link

This is actually creating quite a blocker for me. I'm trying to follow() links and embeds in the Vimeo api using Traverson-hal, but some items contain the specified element, and some don't, so once it finds a null one, it errors out and doesn't parse the api. Help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants