Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to output with specific index?

I want to get specific variable of amount.

Is it possible to say something, like: if index == 1 then return first amount? where possible amounts are: "3333" "444" "555"
If it is possible, how can I do it in the code?

query:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

items{
    name
    amount
  }
const { data } = useQuery(ITEMS)

{data.items.map((items, index) => ( <p>{items.amount}</p>))}

>Solution :

Yes, do this, and you can replace the 1 with whatever index you want (remember, indexing starts at 0, so this 1 means the second value. if you want the first, replace it with 0).

<p>{data.items[1].amount}</p>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading