如何解决通过分页从Rest API调用中加载所有数据花费的时间太长,在加载所有内容之前无法执行任何操作
我遇到了一个问题,因为我的应用程序加载需要花费相当长的时间,因为从我的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);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。