Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Handle pagination REST API

I implemented a function calling a REST API. I defined my query, header, parameters. I wasn't able to manage pagination with loadData() method. How can I achieve my second call to get the page 2 for example ? I tried the recursive way but it didn't work. Here is an response example of HTTP GET request to REST API:

{
"data": [
    {
        ...
       }
        
],
"pageSize": 1000,
"currentPage": 1,
"lastPage": 3,
"totalObjectCount": 2789,
"truncated": false

}

The function I implemented :

    readRestAPI: function (sQuery) {
        var oDataModel = new JSONModel();
        oDataModel.setSizeLimit(2000);
        var oAuthModel = this.getOwnerComponent().getModel("AuthToken");
        var oUserModel = this.getOwnerComponent().getModel("User");
        var sCompanyName = oUserModel.getData().User[0].userCompanyName;
        var sAccountName = oAuthModel.getData().accountName;
        var sToken = oAuthModel.getData().token;
        var iPage = 1;
        var iPageSize = 1000; // Max object for one page in Query API is 1000
        var mParams = {
            "account": sAccountName,
            "company": sCompanyName,
            "query": sQuery,
            "page": iPage,
            "pageSize": iPageSize

        };
        var sURLQueryAPI = "/API/query/v1";
        var sType = "GET";
        var mHeaders = {
            "Authorization": sToken,
            "Content-Type": "application/json",
            "X-Client-ID": sAccountName,
            "X-Client-Version": "1.0.0"
        };
        return oDataModel.loadData(sURLQueryAPI, $.param(mParams, true), true, sType, false, true, mHeaders).then(
            function (resData) {
            return oDataModel;
        });
    }

Could you please explain me how can I handle the pagination ( 1 to 3 for instance )? Thanks

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!