skip to Main Content

I’m trying to call a function with parameters but get this error:

Expected 1 arguments, but got 2

My function call:

await chatHistory(stream, "zzz");

My function:

export const chatHistory = async ({ chatData, chatId }: any) => {....}

2

Answers


  1. As i can see in your code example, you have specified only one argument (of type: object).

    To make your code work, just try:

    await chatHistory({ stream, chatId: "some-Id" });

    This will satisfy the defined arguments of your exported function

    Login or Signup to reply.
  2. The function you created takes only one argument which is an object i.e. {chatDate, chatId}. If you you want two arguments you can use:

    export const chatHistory = async (chatData: any, chatId: any) => {....}

    But if you want to go with your function definition as well, that is also fine. In that case you can use:

    await chatHistory({stream, chatId: "zzz"});

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search