TypeScript Error: "Expected 0-1 arguments, but got 2" when initializing Mux object

85 Views Asked by At

I'm using TypeScript with the Mux library for video handling in my application. As per the documentation, I'm attempting to initialize a Mux object with the required token ID and token secret obtained from environment variables.

However, TypeScript is throwing an error indicating that I'm providing too many arguments to the Mux constructor. The error message I'm receiving is

Expected 0-1 arguments, but got 2.

const {Video} = new Mux(
  process.env.MUX_TOKEN_ID!,
  process.env.MUX_TOKEN_SECRET!,
)

Any assistance or insights would be greatly appreciated. Thank you!

I reviewed the documentation to check if there are any changes to the constructor but it's still not working

1

There are 1 best solutions below

2
Steffen On

You pass an object to Mux with your configuration, it only takes 1 argument, as the error says.

const mux = new Mux({
  tokenId: process.env.MUX_TOKEN_ID, 
  tokenSecret: process.env.MUX_TOKEN_SECRET
});

https://www.npmjs.com/package/@mux/mux-node