Given the following code:
const setFriendCode = (data: Params) => api({ data })
const [mutateSetFriendCode, state] = useMutation<Response, Params>(
setFriendCode
)
Argument of type '(data: Params) => Promise' is not assignable to parameter of type 'MutationFunction<Response, undefined>'. Types of parameters 'data' and 'variables' are incompatible. Type 'undefined' is not assignable to type 'Params'.ts(2345)
To avoid the compilation error I used.
const setFriendCode = (data?: Params) => api({ data })
const [mutateSetFriendCode, state] = useMutation<Response, Params>(
setFriendCode
)
but I want to give 'data' as a required.
How to remove the question mark on data?