0👍
Your response is still inside the axios get method, therefore the makePagination function has to be called inside axios method as well (inside .then())
getAllUserData(){
let $this=this;
axios.get('api/members/getAllMembersData').then(response=>
this.members=response.data.data
$this.makePagination(response.data.meta,response.data.links);
},
makePagination(meta,links){
let pagination={
current_page:meta.current_page,
last_page:meta.last_page,
next_page_url:links.next,
prev_page_url:links.prev
}
this.pagination = pagination;
}
- [Vuejs]-How do I access the data in this dynamic import?
- [Vuejs]-Vue: Importing SCSS only if a component gets created
0👍
axios.get()
is an async function. The code that follows this function will not be executed after the ajax request completes, but long before that. Because of this, the variable response
does not exist yet.
All code that has to be executed when the ajax call completes has to be put in the .then()
function of the call.
getAllUserData(){
axios.get('api/members/getAllMembersData').then(response => {
this.members = response.data.data;
this.makePagination(response.data.meta, response.data.links);
});
},
Source:stackexchange.com