You can use just pure javascript if that is preferred and destucturing to get the array you need. Also, you should change the name of fetch() because it is confusing for anyone reading your code due to the fetch api.
Apr 1, 2018
3
Level 1
getting one array from axios get
Hello everyone,
i have a question:
new Vue({
el: '#root',
data: {
keywords: '',
users: [],
selectedUser: []
},
mounted() {
axios.get('/test').then(response => this.users = response.data);
},
methods: {
fetch() {
axios.get('/fetch', { params: { keywords: this.keywords } })
.then(response => this.selectedUser = response.data)
.catch(error => {});
}
}
});
I fetch all usernames and output them in a select list. Then i search for the selected user and fetch all his data. The Output is then a Array in an Array.
I can only output the userdata with an v-for, is there an option to do this without v-for?
thank you very much
Simon
Level 46
Show us your controller code for the endpoint.
It sounds like you're using a get rather than find or first when fetching the user data.
Please or to participate in this conversation.