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) => {....}
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
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
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"});