我遇到了一个问题,因为我的应用程序需要很长时间才能加载,因为从我的 API 调用中检索到数千条记录,而在加载时我什么也做不了。
是否可以异步加载这些记录,以便在加载时可以在我的应用程序中执行其他任何操作?任何帮助将不胜感激。太感谢了!
这是我的示例代码:
//this method will retrieve records from api
userPagination(url){
var requestObj = {
url: url,
type: "GET",
headers: {
"Content-Type": "application/json"
},
contentype: "application/json",
}
ZDClient.request(requestObj).then(function(assigneeUserObject){
//this will store every user info in assignee_users_fields_all
assigneeUserObject.users.forEach(function(assigneeUser){
this.assignee_users_fields_all.push(assigneeUser);
}.bind(this))
this.usersNextPage = assigneeUserObject.next_page;
if(assigneeUserObject.next_page != undefined){
this.userPagination(this.usersNextPage);
}
}.bind(this), function(err){
}.bind(this))
},
//This method will call the userPagination() method
getTicketAssigneesUser(){
this.usersNextPage = "/api/v2/users.json?page=1";
this.userPagination(this.usersNextPage);
}