データベースへの呼び出しを使用して結果を取得し、それらを配列にプッシュしています。ただしconsole.log(this.activeBeers)
、配列ではなくオブジェクトが返される場合。オブジェクトの代わりに単純な配列を取得するにはどうすればよいですか?
Vue.component('beers', {
template: '#beers-template',
data: function() {
return {
activeBeers: []
}
},
ready: function() {
function getActiveBeers(array, ajax) {
ajax.get('/getbeers/' + $('input#bar-id').val()).then(function (response) {
$.each(response.data, function(key, value) {
array.push(value.id);
});
}, function (response) {
console.log('error getting beers from the pivot table');
});
return array;
}
console.log(this.activeBeers = getActiveBeers(this.activeBeers, this.$http));
},
props: ['beers']
});