Currently, I am retrieving JSON data from an API call using axios and displaying it through Vue.
This snippet shows the JSON Object logged in the console:
0:
category_id: "categ1"
item_name: "item1"
price: 100
stock: 155
1:
category_id: "categ2"
item_name: "item2"
price: 100
stock: 155
2:
category_id: "categ1"
item_name: "item3"
price: 100
stock: 155
3:
category_id: "categ3"
item_name: "item4"
price: 100
stock: 155
Below is the mounted function in my Vue instance where I make use of axios for API calls:
mounted () {
axios.get('link_for_api_endpoint', {
headers : {
Authorization: 'Bearer ' + access_token,
},
params: {
limit: 250
}
})
.then((response) => {
this.data = response.data.items;
//console.log(response);
$("#ldr").hide();
removeLoader();
})
.catch(function (error) {
console.log(error);
})
.then(function () {
});
}
My goal is to filter out data that has a category value of "categ1" from the entire JSON object. How can I achieve this specific filter?