type "number" cant be used to index list
Im getting this error, help would be great!
11 Replies
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
like this? @Brendonovich
Where do you assign randomLongOrd a value?
You’d probably be better off awaiting it at that point instead
This is where i'm assigning it
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[]>
That fixed the error! Thanks a bunch, would you mind helping me understand why it was caused in the first place?
i think it should be
OrdLong[]
not OrdLong
The main problem is that you were dealing with PrismaPromise
without await
ing it
number
can index any array, but you were trying to index PrismaPromise
since you didn't have await
Ah right, i was saying that it was a prisma promise evn though i was awaiting it!
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 notCould i ask you for help with another related issue?
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