Closed treyorr closed 1 month ago
Hello. I am trying to implement a RTK mutation in which I pass in two arguments in a Typescript project.
export const exampleApi= createApi({ reducerPath: "myPath", baseQuery: fetchBaseQuery({ baseUrl: url }), endpoints: (builder) => ({ sendVerificationText: builder.mutation({ query: (phone: string) => ({ url: "user/sendVerificationText", method: "POST", body: { phone }, }), }), verifyVerificationCode: builder.mutation<any, VerificationCodeRequestBody>({ query: (body) => { return { url: "user/verifyVerificationCode", method: "POST", body: body, }; }, }), }), });
I am attempting to pass in two variables using the method in the hook generated by RTK.
verifyVerificationCode({ phone, otp });
However, I keep recieving the error: Argument of type '{ phone: string; otp: string; }' is not assignable to parameter of type 'string'.
Argument of type '{ phone: string; otp: string; }' is not assignable to parameter of type 'string'.
I have read previous inquiries into this behavior, but yet the solution still is evading me. Thank you.
Sorry , I had a really dumb mistake that evaded me for a few hours. This can be closed since I was using the wrong hook
Hello. I am trying to implement a RTK mutation in which I pass in two arguments in a Typescript project.
I am attempting to pass in two variables using the method in the hook generated by RTK.
verifyVerificationCode({ phone, otp });
However, I keep recieving the error:
Argument of type '{ phone: string; otp: string; }' is not assignable to parameter of type 'string'.
I have read previous inquiries into this behavior, but yet the solution still is evading me. Thank you.