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

Unable to instantiate the EdgeGrid class in Typescript #241

Open
juananinca opened this issue Feb 19, 2025 · 3 comments
Open

Unable to instantiate the EdgeGrid class in Typescript #241

juananinca opened this issue Feb 19, 2025 · 3 comments

Comments

@juananinca
Copy link

I'm using these versions:

  • akamai-edgegrid: 3.5.2
  • node: v20.12.2
  • npm: 10.5.0
  • typescript: 5.6.3

Here is where I'm instantiating the class EdgeGrid:

import EdgeGrid from "akamai-edgegrid";

const createEdgeGridClient = () => {
    const clientToken = process.env.AKAMAI_CLIENT_TOKEN;
    const clientSecret = process.env.AKAMAI_CLIENT_SECRET;
    const accessToken = process.env.AKAMAI_ACCESS_TOKEN;
    const baseUri = process.env.AKAMAI_BASE_URL;

    if (!clientToken || !clientSecret || !accessToken || !baseUri) {
        throw new Error("Missing Akamai EdgeGrid configuration environment variables");
    }

    return new EdgeGrid(clientToken, clientSecret, accessToken, baseUri);
}

But when I try to run project I get this message:

2025-02-19T14:15:11.333Z [error] akamai_edgegrid_1.EdgeGrid is not a constructor

Every example I've found in this repo or somewherelse is in javascript but nothing in Typescript.

Any help would be useful.

@PawelSnoch
Copy link

Hello @juananinca ,

thank you for rising this topic. We apologize for lack of TypeScript example. I will create an internal ticket to fill that gap.

Unfortunately, I am not able to reproduce your error. It seems that your code works on my environment. Could you try a different approach? I would recommend you to load API client from edgerc file:

let edgeGridClient = new EdgeGrid({
path: '/path/to/.edgerc',
section: 'section-header'
});

Please let me know if this helps.

Best regards,
Pawel

@juananinca
Copy link
Author

Hi @PawelSnoch,

Same result using the credentials file ".edgerc".

import EdgeGrid from 'akamai-edgegrid';

const createEdgeGridClient = () => {
    // const clientToken = process.env.AKAMAI_CLIENT_TOKEN;
    // const clientSecret = process.env.AKAMAI_CLIENT_SECRET;
    // const accessToken = process.env.AKAMAI_ACCESS_TOKEN;
    // const baseUri = process.env.AKAMAI_BASE_URL;

    // if (!clientToken || !clientSecret || !accessToken || !baseUri) {
    //     throw new Error("Missing Akamai EdgeGrid configuration environment variables");
    // }

    // return new EdgeGrid(clientToken, clientSecret, accessToken, baseUri);
    return new EdgeGrid({
        path: './.edgerc',
        section: 'default'
        });
}

output:
akamai_edgegrid_1.default is not a constructor

@ckulinsk
Copy link

ckulinsk commented Mar 4, 2025

Hi @juananinca
We are still unable to reproduce your issue, could you please provide us more details?
File which is causing issues with obfuscated data would be greatly appreciated.

Best regards,
Cyryl

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

No branches or pull requests

4 participants