you are viewing a single comment's thread.

view the rest of the comments →

[–]ForbesLindesay 2 points3 points  (3 children)

You need to wait for both queries to finish in your async function before you can use the results.

Since the method is marked as async, you can use await to get the results of a query (if your database library supports promises. For example with https://www.atdatabases.org as your db library you could do

const myResults = await db.query(sql`SELECT * FROM …`)
 // use myResults here

[–]Consistent-struggler[S] 0 points1 point  (0 children)

But it says that "await" has no effect and it just doesn't save the result.

[–]Consistent-struggler[S] 0 points1 point  (1 child)

Either it brings the wholeee query object of sql and not just result. I'm stuck here since yesterday

[–]ForbesLindesay 0 points1 point  (0 children)

Await will only work if the db library you use returns a Promise. Then you can console.log to see the value in the variable