通过分页从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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...