Cannot make D1 requests twice?
I am facing a strange issue where I am unable to make D1 queries multiple times. Here is the code I am using
If I run this code the console shows the first log is normal, but the second console.log returns undefined. What is going on here and how do I fix it?
4 Replies
Because contextVerses doesn’t exist on a D1Result I assume? You’re destructuring.
Im sorry, what does this mean? And how do I fix it?
Why does it work on one var and not the other when they are exactly the sam except for names?
okay declaring the var with {} and then accessing .results yields the correct value, but im still really confused on why this is happening
Because you’re destructuring, you’re accessing a property - and “contextVerses” isn’t a property
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
MDN Web Docs
Destructuring assignment - JavaScript | MDN
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.