Answered

Typeform-js-client library issue


Userlevel 2
Badge

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?

 

icon

Best answer by mathio 24 June 2022, 17:49

View original

7 replies

Userlevel 7
Badge +5

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

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

Userlevel 2
Badge

@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

Userlevel 7
Badge +5

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

Userlevel 2
Badge

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

Userlevel 7
Badge +5

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.

Userlevel 2
Badge

Ah ok, I’ll try that

Userlevel 7
Badge +5

Let us know if it works! @propfunnel 😉

Reply