I'm a beginner when it comes to TypeScript and I am using react-query
. I tried using mutate
, but it is causing an error.
TS2554: Expected 1-2 arguments, but got 3.
interface:
interface ChangePassword{
email: string;
password: string;
confirmPassword: string
}
function:
const changePasswordOnClick = useMutation<Record<string, string>, unknown, ChangePassword>(
() => axios.post(
url,
{ email, password, new_password}, // all fine
),
{
onSuccess: (req) => {
console.log('Request', req)
},
onError: (newLogin) => {
console.log('onError', newLogin);
},
},
);
Problem (just a snippet):
onSubmit={async (data,
{setSubmitting, resetForm})=>{setSubmitting(true)
changePasswordOnClick.mutate(
data.email,
data.password,
data.confirmPassword)} // TS2554: Expected 1-2 arguments, but got 3.
Why am I encountering this error? How can I resolve it?