Pagination in an external API

Options
Hey everyone, 

Trying to pull a contact list from Productive (productive.io) and the request pulls 30 results per page. 

I have the for loop to pull everything off the page (and it's working), but I'm not sure how to move between the pages (and pull the next set of results). In the meta information I can see the current_page and the total_pages but I wanted to see if anyone had suggestions on the best way of tackling this. 

Thanks!

Comments

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options
    Hey, Kevin! Productive lists pagination in their documentation here so it should hopefully be as simple as passing the page number in your API call. What I'm not seeing is how to reference the total number of pages, so you know how many times your function needs to run. Do you have a static number of pages you'd be working with, or will this value change?
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    This tutorial should help, the APIs might be a little different but it should be a similar framework


    
  • Kevin Wessa
    Kevin Wessa Member
    Options
     thanks for your message! I've been eyeing up Xano for a long time and it's nice to start using the system.

    And thanks  for recommending that video. I had seen it prior to reaching out on support, but spending more time carefully watching, I was able to translate it for my use case. 
     
    I got everything working. I pull in each page, map it to the database, and update the page variable until it reaches the maximum. It was really cool to see everything working!

    This isn't related to my original question (on pagination), but when it came to mapping the phone number field from Productive in a (123) 456-7890 format, it came back with the error message "Text filter requires a scalar value." Are there any videos that explain how to get phone numbers into Xano? 

    Thanks for all your help!
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     Awesome - very glad to hear. Paging metadata can be a bit different depending on the API so glad you were able to translate the concept over to your use case and get it rocking!

    "Text filter requires a scalar value" - is typically thrown when there is a mismatch of data types. Is it possible to check if your phone number is coming back in an array? If it comes in between flat brackets [] ? (Arrays are often, but not always the culprit)
  • Kevin Wessa
    Kevin Wessa Member
    Options
     you're spot on! It was in an array. 

    I've set myself up for office hours in a few weeks to go through how to fix something small like this (and other little questions I have). 

    Thanks for everything! Xano is simply amazing.