Parameters limit on paginated list of members Answered

Post author
TheStyle134 null

hi guys. here it says default is 50 but doesnt name the maximum. what is it ? 💓

Comments

10 comments

  • Comment author
    Tyler Bell

    Max is 100.

    0
  • Comment author
    TheStyle134 null

    is it possible to ask for more?

    0
  • Comment author
    Tyler Bell

    Beyond 100, you’ll need to paginate.
    Where are you using the api?

    I can give you example code.

    0
  • Comment author
    TheStyle134 null

    google cloud console, tho. i'd appreciate!

    0
  • Comment author
    Tyler Bell

    What language?

    0
  • Comment author
    TheStyle134 null

    node js

    0
  • Comment author
    Tyler Bell

    Sweet.

    Yeah I’ll send you some code.

    can you use NPM packages in your project?

    We have a NPM package that makes using our API easier.

    0
  • Comment author
    TheStyle134 null

    im not using webflow, but a more limiting cms. that s why i am using gcf.

    so no, i can not use npms

    0
  • Comment author
    Tyler Bell

    do you know what version of node you are using?

    const API_KEY = //your MS secret key; const BASE_URL = 'https://admin.memberstack.com/members'; async function fetchMembers(url, headers) { try { const response = await fetch(url, { headers }); if (!response.ok) { throw new Error(`Error: ${response.status}`); } return await response.json(); } catch (error) { console.error('Failed to fetch members:', error); return null; } } async function listAllMembers(after = null, order = 'ASC', limit = 50) { const url = new URL(BASE_URL); if (after) url.searchParams.append('after', after); url.searchParams.append('order', order); url.searchParams.append('limit', limit); const headers = { 'X-API-KEY': API_KEY }; const membersData = await fetchMembers(url, headers); if (membersData && membersData.hasNextPage) { const nextMembers = await listAllMembers(membersData.endCursor, order, limit); return membersData.data.concat(nextMembers); } else { return membersData ? membersData.data : []; } } // Usage listAllMembers().then(members => { console.log('Total Members Fetched:', members.length); console.log('Members:', members); });
    the code above assumes you are using node v18 or higher.
     
     
     
    0
  • Comment author
    TheStyle134 null

    thankies!

    0

Please sign in to leave a comment.