[Adonis 4.1] Error on view loop (Edge template) #1432
-
my view is looping for a result that is larger than expected and still with error and where there is no error it is duplicated, if I put it to be passed to the view with .toJSON it will not |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't get whats the issue here? You say result is larger than expected. what is expected? |
Beta Was this translation helpful? Give feedback.
-
TLDR: You are looping over object keys, not array
Now when you pass it as Most likely you want to make it |
Beta Was this translation helpful? Give feedback.
TLDR: You are looping over object keys, not array
findBy
returns single result, like you can see, it's just an object, not an array:Now when you pass it as
receipts:receipt
to viewreceipts
is single object, not an arrayNext you are looping over Object, which has 11 keys.
Most likely you want to make it
await Receipt.query().where({user_id: user.id}).fetch()