Skip to content

TypeError when parsing a row: parse-row.js #6

Description

@hunsoo
TypeError: Cannot read property 'v' of null
    at ...../node_modules/cuba/src/parse-row.js:10:71

This happens when checking for null with:

result[schema[index]] = transform(typeof cell === 'object' ? cell.v : null)

When you do typeof null, you get 'object'.
It can be fixed by checking for the null with double negation, because the cell is either an object literal (which always returns true when used in conditional statements) or null:

result[schema[index]] = transform(!!cell ? cell.v : null) 

This works fine with my data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions