const [updateFn, { loading, data, error }] = useUpdate(url, options)
url: string 请求的 URL。
url: string
options?: Options
method (String) - HTTP method. 默认: GET
GET
body (Object, body types) - HTTP request body
headers (Object, Headers) - 默认: {}
和 fetch 的异同:TODO:
updateFn: (options: Options)
一个用来触发 update 的函数,例如:addTodo({ title: 'one thing'})。
addTodo({ title: 'one thing'})
loading: boolean
请求状态,是否成功获取数据,对前端界面状态处理很有用。
data: TData
GraphQL 查询成功返回的数据对象,例如:
error: TError
请求发生错误时,返回的错误信息对象,例如:
Last updated 7 years ago
Was this helpful?
{ hero: { name: 'Cristiano Ronaldo' } }
{ error: { statusCode: 401, error: "Unauthorized", message: "未登录" } }