Skip to content

Uncaught TypeError: Clockify is not a constructor #12

@brunobe

Description

@brunobe

After going through the readme file, I couldn't get the Clockify api wrapper to work. The issue is probably my limited knowledge of Typescript as I am just a novice. But because I could not find a solution, I had no better idea than asking it here.

When executing the code (no 'compilation' errors) the runtime throughs the error: "Uncaught TypeError: Clockify is not a constructor".

When reading through the code, I came to the same conclusion: the Clockify class or the class it extends from (ClockifyAPI), has a constructor method without an implementation. Or at least an implementation I can't deduce from the code.

Do you have any suggestions on what the issue could be?

My code:

import { readFile } from 'fs/promises';
import Clockify from "clockify-ts";

let config = await readFile('ftconfig.json', {encoding: 'utf-8'}).then((text: string) => JSON.parse(text));

const env = config.env.production.aig;
const apiKey = env.apiKey;
const workspaceId = env.workspaceId

const clockify = new Clockify(apiKey); // error
const projects = await clockify.workspace.withId(workspaceId).projects.get();
console.log(projects);

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions