1 Reply Latest reply on Jan 2, 2020 10:54 AM by gbrettmiller

    How to create pagination with links.next and links.previous

    babi_maji Novice

      The links object gives us the option to paginate. What is the best practice to execute pagination with these fields?

       

      Jens Goldhammer can you shed some context here?

       

      Cheers!

        • Re: How to create pagination with links.next and links.previous
          gbrettmiller Beginner

          The approach I've used is to include an if/then right before the return statement to check the links object for the existence of a next = "" item, and if it exists to send that link back to the function to execute.

           

          if (links.next === undefined || links.next == ""){
               //there is no next link, do the stuff you want to do
          } else {
               //there is a next link, send it as a parameter back to original function
          }
          return;

          2 people found this helpful