Answer the question
In order to leave comments, you need to log in
How to organize ajax filtering vue.js according to the criteria specified in the array?
Here is the code.
When changing the selected elements, it is necessary to send a request according to these criteria (The code of the checklisted sheets put into the array already exists and works)
For example, an array in which the keys are set.
Using these keys (filter), you need to filter data.json for the similarity of the value in it arr[N].flights[N].airline.code === "KC" and, if so, write this element to another array (arr[ N]) with data.json
filter = ['KC', 'Z9', 'DV'];
Answer the question
In order to leave comments, you need to log in
Add the flightsData property, where you will add the data, initially - an empty array.
Display its contents in a template, for example:
<div v-for="item in flightsData">
<div>Price: {{ item.price }}</div>
<div v-for="f in item.flights">
<div>Departure: {{ f.cities.departureCity }}, {{ f.departureTime }}</div>
<div>Arrival: {{ f.cities.arrivalCity }}, {{ f.arrivalTime }}</div>
</div>
</div>
this.flightsData = response.data.filter(n => val.includes(n.flights[0].airline.code));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question