我需要在按下提交按钮时调用查询,然后处理响应。
我需要这样的东西:
const [checkEmail] = useLazyQuery(CHECK_EMAIL)
const handleSubmit = async () => {
const res = await checkEmail({ variables: { email: values.email }})
console.log(res) // handle response
}
Run Code Online (Sandbox Code Playgroud)
尝试 #1:
const [checkEmail, { data }] = useLazyQuery(CHECK_EMAIL)
const handleSubmit = async () => {
const res = await checkEmail({ variables: { email: values.email }})
console.log(data) // undefined the first time
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!