Skip to content

[Adonis 4.1] Error on view loop (Edge template) #1432

Answered by McSneaky
brandonsousa asked this question in Help
Discussion options

You must be logged in to vote

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:

Find a record using a key/value pair. Returns the first matching record.
https://adonisjs.com/docs/4.0/lucid#_findby_findbyorfail

Now when you pass it as receipts:receipt to view receipts is single object, not an array
Next 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()

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@brandonsousa
Comment options

Comment options

You must be logged in to vote
1 reply
@brandonsousa
Comment options

Answer selected by brandonsousa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants