team-telnyx / telnyx-node

Node SDK for the Telnyx API
https://developers.telnyx.com/docs/api/v2/overview
MIT License
54 stars 20 forks source link

`for-await-of` example not working for simCards #148

Closed pbelbin closed 1 year ago

pbelbin commented 1 year ago

Here is documentation that I'm trying to follow with:

import Telnyx from 'telnyx';
const telnyx = Telnyx('{your key}');

(async () => {
  const { data: simCardList } = await telnyx.simCards.list({
    //filter: { tags: ["region_5", "ext_cards"] },
    include_sim_card_group: true,
    page: { size: 250 }
  });

  console.log('simCardList:', simCardList);

  for await(const simCard of telnyx.simCards.list()) {
    console.log('card:', simCard);
  }
})();

The console.log('simCardList:'......) shows an object having the expected elements. So far, so good.

However, when it gets to the for-await-of, I get the following error:

Uncaught Error Error: Unexpected: Telnyx API response does not have a well-formed `data` array.
    at iterate (d:\archives\telnyx\api\node_modules\telnyx\lib\autoPagination.js:13:13)
    at processTicksAndRejections (internal/process/task_queues:95:5)

This is with the latest version of the telnyx-node library as of writing (1.23.0).

Node version is: v18.12.1

It seems from the documentation, that the for-await-of should function ok, but clearly something is not happy.

Please advise.

ADandyGuyInSpace commented 1 year ago

I think this should be resolved with the latest (1.25.5 and onwards) update as the testing for that endpoint did resolve, but let me know if this is still ongoing and open up another issue. The testing suite should be much more elaborate now to catch stuff like this