javascript - 通过分页从 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);
}
解决方案
推荐阅读
- c# - Web 服务 - Azure 云服务中未找到文件异常
- swift - 使用@IBInspectable Swift 4.2 的 UIView 上的 CornerRadius 和阴影
- json - Viber REST API[GATEWAY_TIMEOUT]
- java - 如何在 Spring Boot wicket 应用程序中注入 RequestScope bean
- android - Android Studio 模板包名
- azure - Azure Functions 中的 Chrome 运行失败:尝试以访问权限禁止的方式访问套接字
- visual-studio - 解决方案文件中的差异
- delphi - Delphi,记录类型属性,记录字段分配:预期分配到记录的本地副本
- architecture - 低延迟,服务器推送。服务器可以有多少个打开的连接?
- c# - C# XML 标记到 csv