Skip to content

Halfred can't parse Resources with null embeds #34

Open
@gcaseres

Description

@gcaseres

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions