Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Error: Key is not defined #17

@arjunpola

Description

@arjunpola

After creating the first Entity it and try to run the node app according to STEP-6 I get the following error.

Running on http://localhost:8080/
/home/user_name/cloud-nodejs/start/app.js:40
    var keyBooks = books.map((book) => Object.assign(book, { id: book.id || book[key].path[1] }));
                                                                                 ^
ReferenceError: key is not defined
    at books.map (/home/user_name/cloud-nodejs/start/app.js:40:82)
    at Array.map (native)
    at /home/user_name/cloud-nodejs/start/app.js:40:26
    at /home/user_name/cloud-nodejs/start/node_modules/google-cloud/node_modules/@google-cloud/datastore/src/request.js:577:7
.....

Solution:

I works when I change from id = 0 to id = 1 for the entity I created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions