Skip to content
Advertisement

Electron, Javascript: How to select an array within an array returned by the database

I want to foreach an array to show on the screen. This array is the data from a database table.

The code to get this data:

JavaScript

But this variable comes this way:

enter image description here

And I’m not able to select that array (_rejectionHandler0)

Advertisement

Answer

Since .query also returns a Promise, you need to await it.

JavaScript

await conn waits for the connection to be obtained and the outer await waits for the query to finish.

Alternatively, you can await each one separately:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement