type "number" cant be used to index list

Im getting this error, help would be great!
11 Replies
Brendonovich
Brendonovich2y ago
You probably need to await randomLongOrd since it’s a promise. Then you’ll have access to the actual list that you can access with randomNum
Christian Lind
Christian LindOP2y ago
like this? @Brendonovich
Brendonovich
Brendonovich2y ago
Where do you assign randomLongOrd a value? You’d probably be better off awaiting it at that point instead
Christian Lind
Christian LindOP2y ago
This is where i'm assigning it
Brendonovich
Brendonovich2y ago
ah, i'd suggest doing as OrdLong[] outside of the await so that you don't need the PrismaPromise parth oh actually u can use a generic argument like $queryRaw<OrdLong[]>
Christian Lind
Christian LindOP2y ago
That fixed the error! Thanks a bunch, would you mind helping me understand why it was caused in the first place?
Brendonovich
Brendonovich2y ago
i think it should be OrdLong[] not OrdLong The main problem is that you were dealing with PrismaPromise without awaiting it number can index any array, but you were trying to index PrismaPromise since you didn't have await
Christian Lind
Christian LindOP2y ago
Ah right, i was saying that it was a prisma promise evn though i was awaiting it!
Brendonovich
Brendonovich2y ago
Ohhh that's a good point actually, you were overriding it to a promise even though you already awaited it I wasn't sure whether the await was added after i suggested it or not
Christian Lind
Christian LindOP2y ago
Could i ask you for help with another related issue?
Christian Lind
Christian LindOP2y ago
Im an error where it is complaining and saying "Unsafe member access .meaning on an any value." .But the type does in fact have an attribute called meaning
Want results from more Discord servers?
Add your server