Home > database >  Fetching two type of data from same API
Fetching two type of data from same API

Time:03-11

I want to use two type of data like I am making a pizza order app and I have use this api- https://run.mocky.io/v3/ec196a02-aaf4-4c91-8f54-21e72f241b68, I want to toggle between veg and non veg and in that api there is veg and non veg boolean. tell me how to use it in React components enter image description here

CodePudding user response:

const data = await response.json();
const transformedVegPizzas = data.filter(f=> f.isVeg).map( /* your code */);
const transformedNonVegPizzas = data.filter(f=> !f.isVeg).map( /* your code */);
  • Related