0

The question is the same of the title: How to filter a json result using react native?

I have a simple json result:

[{"id":"1","title":"Outlet_Usou","category":"Rouparia","latitude":"-8.616075000000000","longitude":"-35.95577800000000"},
 {"id":"2","title":"Studio F7","category":"Academia","latitude":"-8.609749000000000","longitude":"-35.94622500000000"},
 {"id":"3","title":"Pizzaria Popular","category":"Pizzaria","latitude":"-8.599646000000000","longitude":"-35.95055900000000"}]

I receive and list this json using map function.

How do can I filter for title or category fields?

1 Answer 1

3

Let's say your array is assigned to a variable data:

const pizzerie = data.filter( (item) => {
  return item.category === 'Pizzaria'
})

This would give you an array (pizzerie) of data objects that match that category. You can edit to check titles...whatever.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.