cloud-nodejs icon indicating copy to clipboard operation
cloud-nodejs copied to clipboard

Error: Key is not defined

Open arjunpola opened this issue 7 years ago • 4 comments

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.

arjunpola avatar Mar 30 '17 21:03 arjunpola