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

Cannot read 'id' from property #1

Open
aLearningProcess opened this issue Apr 25, 2023 · 2 comments
Open

Cannot read 'id' from property #1

aLearningProcess opened this issue Apr 25, 2023 · 2 comments

Comments

@aLearningProcess
Copy link

Hi, first ever GitHub issue being created, so please be kind: :)

I am a python programmer, so don't know Node or JS as much. I've run down the rabbit hole of trying to find solutions, but I don't know how to implement most of the suggestions to try them out.

https://stackoverflow.com/questions/67193689/node-js-typeerror-cannot-read-property-id-of-undefined

My Error:
(node:116947) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
at /home/usaspending-gpt4/.npm/_npx/cda643d17fed3bae/node_modules/ask-your-database/dist/index.js:70:188
at Array.map ()
at /home/usaspending-gpt4/.npm/_npx/cda643d17fed3bae/node_modules/ask-your-database/dist/index.js:70:39
at Array.map ()
at main (/home/usaspending-gpt4/.npm/_npx/cda643d17fed3bae/node_modules/ask-your-database/dist/index.js:69:49)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:116947) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:116947) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@egitto
Copy link

egitto commented Jun 14, 2024

That's probably going to be this bit of code. exampleRows[tableName][column.column_name]. It sounds like it doesn't have any example rows for your table. It looks like it grabs an example row for each table by querying the table here

  for (const tableName of Object.keys(tables)) {
    const exampleRow = await db(tableName).first();
    exampleRows[tableName] = exampleRow;
  }

So I suspect your table (or one of your tables, at least) is empty and you need to insert a row for this project to work.

@carlors
Copy link

carlors commented Nov 13, 2024

I find a solution to solve this problem,just change the code as below:

  for (const tableName of Object.keys(tables)) {
    const exampleRow = await db(tableName).first();
    exampleRows[tableName] = exampleRow || {};
  }

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

3 participants