Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda