Display data from objects of hits

Hey Algolia community,
I’am having some difficulties to fetch data from ‘hits’ objects: this is my json :


i want to access the donations attributes, i have tried on html _highlightResult.donations (it shows [Object, object]…) and tried either _highlightResult.donations[0].montant but nothing appears.
Best Regards.

Hi @mabrouk.yassine4

Mustache templates works with dot even for numerical index.

You might wanna try :

_highlightResult.donations.0.montant

Hope this helps :wink:

Hello,

Did you add “donations.montant” in your “attribute to Highlight” in your dashboard ? (tab display)

Let me know :slight_smile:

Hey pierre, I’m happy that you helped me out, it’s working but it shows only the variable at a precise inexd donations.0. for example.
Don’t know yet how am going to iterate hough it.

I’m on mobile so sorry for short answers!

Hey dear baptiste, thanks for your support, and for your question i don’t want to change the highlighted object. thanks

Thank you Piere it worked as a charm, now am gonna try to sum the resulted numbers. thank you again

Glad I helped @mabrouk.yassine4

I believe Mustache templating supports most of numerical operators like + * etc…

Don’t forget to identify a post Solution so everyone knows this topic is close :wink:

1 Like