Reputation: 322
I'm using a google spreadsheet to get data from an "api" to my vue.js website.
I'm collecting all data for now and I would like to know if this was possible for me to get data with a condition on a table column like "category == 'football'". And then i get only row with the catefory football like in an SQL request.
Here is my created code and this.items is a simple array :
created(){
this.axios.get("https://spreadsheets.google.com/feeds/list/my-id/1/public/full?alt=json")
.then(response => (this.items = response.data.feed.entry))
},
And if this is not possible do someone have any idea on how to filter directly in my array.
Upvotes: 2
Views: 748
Reputation: 1920
@AntoineKurka something like this may work for you.
async created() {
let response = await this.axios.get("https://spreadsheets.google.com/feeds/list/my-id/1/public/full?alt=json")
let items = response.data.feed.entry
let filteredItems = items.filter(item => {
return item.category === 'football'
})
}
Where filteredItems
will be your filtered array.
If you were planning on then setting this array to a property in your data()
section, you could instead just do
this.someProperty = items.filter(item => {
return item.category === 'football'
})
Upvotes: 1