Typeform-js-client library issue | Community
Skip to main content
Answered

Typeform-js-client library issue


Forum|alt.badge.img

Hi, I use the typeform-js-library to retrieve all the forms and responses. But I’m encountering some issues where the list just doesn’t seem to work like this.

 

    typeformClient
            .forms
            .list(page=2)

 

If I change the page, the result stay the same. Can someone tell me how to pass the query parameters properly if I’m doing it wrong? Or is this the wrong way?

 

Best answer by mathio-tf

Thanks, that library is ours indeed 😃

 

I tried the following code and it works for me, each call returns “items” array with different typeforms:

const pages = await Promise.all([
  typeformAPI.forms.list({ page: 1 }),
  typeformAPI.forms.list({ page: 2 }),
  typeformAPI.forms.list({ page: 3 })
]);

console.log("pages", pages);

 

I see you have a weird syntax in your code: 

.list(page=2)

That is not how you pass an object in JS, maybe thats your issue? However your IDE or JS engine should complain about that syntax.

 

Are you sure you have more pages of typeforms available? The API call should return something like this:

  {
    total_items: 47,
    page_count: 5,
    items: [ ... ]
  }

However if you specify invalid page the API should return an empty “items” array.

View original

7 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14960 replies
  • June 22, 2022

Hi @propfunnel Could you send the full call you’re making? Thanks!

Tagging @mathio and @picsoung in case they have some advice as well. 


Forum|alt.badge.img
  • Author
  • Explorer
  • 8 replies
  • June 23, 2022

@Liz 


router.get('/typeform/forms', (req, res) => {
        typeformClient
            .forms
            .list(page=2)
            .then((data) => {
                console.log(data.items)
                res.header(200).json(data)
            })

})

 

Here’s the full call, I’m using express.js to call the function


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • June 23, 2022

Hello @propfunnel , what is typeform-js-library? I am not familiar with it and google search does not help much.


Forum|alt.badge.img
  • Author
  • Explorer
  • 8 replies
  • June 24, 2022
mathio wrote:

Hello @propfunnel , what is typeform-js-library? I am not familiar with it and google search does not help much.

Hey,

 

here is the link to the api-client

 

https://www.npmjs.com/package/@typeform/api-client


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • Answer
  • June 24, 2022

Thanks, that library is ours indeed 😃

 

I tried the following code and it works for me, each call returns “items” array with different typeforms:

const pages = await Promise.all([
  typeformAPI.forms.list({ page: 1 }),
  typeformAPI.forms.list({ page: 2 }),
  typeformAPI.forms.list({ page: 3 })
]);

console.log("pages", pages);

 

I see you have a weird syntax in your code: 

.list(page=2)

That is not how you pass an object in JS, maybe thats your issue? However your IDE or JS engine should complain about that syntax.

 

Are you sure you have more pages of typeforms available? The API call should return something like this:

  {
    total_items: 47,
    page_count: 5,
    items: [ ... ]
  }

However if you specify invalid page the API should return an empty “items” array.


Forum|alt.badge.img
  • Author
  • Explorer
  • 8 replies
  • June 25, 2022

Ah ok, I’ll try that


Gabi Amaral
Ex–Typefomer
Forum|alt.badge.img+5
  • Ex–Typefomer
  • 1777 replies
  • June 27, 2022

Let us know if it works! @propfunnel 😉


Reply