NewbieCoder
NewbieCoder

Reputation: 95

launchDarkly getting TypeError: URL is not a constructor

I'm tring to get passed this error and can't seem to. This is the line I'm getting it on.

const client: LDClient = LaunchDarkly.init(key);

I'm using typescript, NextJS. I'm using react-client-sdk version 3.0.10 and node-server-sdk version 7.0.3 of LaunchDarkly.

Upvotes: 0

Views: 95

Answers (1)

NewbieCoder
NewbieCoder

Reputation: 95

This is what I did to get past this error.

export async function getClient(): Promise<LaunchDarkly.LDClient> {
  const client = LaunchDarkly.init(process.env.LAUNCHDARKLY_SDK_KEY!);
  await client.waitForInitialization();
  return client;
}

Upvotes: 0

Related Questions