Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] SDK's getServices results in an error @ v23.5.1 #155

Closed
moritzjacobs opened this issue Nov 21, 2024 · 3 comments
Closed

[Bug] SDK's getServices results in an error @ v23.5.1 #155

moritzjacobs opened this issue Nov 21, 2024 · 3 comments

Comments

@moritzjacobs
Copy link

moritzjacobs commented Nov 21, 2024

I'm not really familiar with the inner workings of this SDK, I just noticed that something stopped working in my app, so I poked into it:

/v3/services results in { "services": […], filter: … } yet the SDK assumes paging info? See the error below.

If you change the object access to optional chaining it works:

    const remainingPages = Array.from(
      { length: paging?.countPages - 1 }, // added the ? here
      (_, index) => index + 2
    );

Repro:

v23.5.1

import { Clockodo } from "clockodo";

const clockodo = new Clockodo({
  client: {
    name: "Foo Bar",
    email: "[email protected]",
  },
  authentication: {
    user: "[email protected]",
    apiKey: "…",
  },
});

const main = async () => {
  console.log(await clockodo.getServices());
};

main();
➜  node index.js 
file:///…/node_modules/clockodo/dist/lib/api.js:168
            const remainingPages = Array.from({ length: paging.countPages - 1 }, (_, index) => index + 2);
                                                               ^

TypeError: Cannot read properties of undefined (reading 'countPages')
    at Api.getPagesStreaming_1 (file:///…/node_modules/clockodo/dist/lib/api.js:168:64)
    at getPagesStreaming_1.next (<anonymous>)
    at resume (file:///…/node_modules/clockodo/dist/lib/api.js:28:44)
    at file:///…/node_modules/clockodo/dist/lib/api.js:27:121
    at new Promise (<anonymous>)
    at i.<computed> [as next] (file:///…/node_modules/clockodo/dist/lib/api.js:27:63)
    at Api.<anonymous> (file:///…/node_modules/clockodo/dist/lib/api.js:177:97)
    at Generator.next (<anonymous>)
    at fulfilled (file:///…/node_modules/clockodo/dist/lib/api.js:4:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.14.1
@moritzjacobs moritzjacobs changed the title [Bug] SDK's getServices results in an error [Bug] SDK's getServices results in an error @ v23.5.1 Nov 21, 2024
@florianwittmann
Copy link
Collaborator

Thanks for reporting @moritzjacobs. We found the underlying problem and are on it to fix it. I will update you as soon as it is fixed.

@florianwittmann
Copy link
Collaborator

The error should be fixed on our side - no package update needed. Could you please try again and confirm @moritzjacobs?

@moritzjacobs
Copy link
Author

I can confirm, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants