摘要: 最简单的方式是检查响应的 Content-Type 头部,看它是否指定了 JSON 类型。大多数服务器会在返回 JSON 数据时设置正确的 Content-Type 头部为 application/json。 const contentType = response.headers.get('con 阅读全文
posted @ 2024-07-11 15:25 红苹果学园 阅读(2) 评论(0) 推荐(0) 编辑
摘要: import useSWR from 'swr' function Profile() { const { data, error, isLoading } = useSWR('/api/user', fetcher) if (error) return <div>failed to load</d 阅读全文
posted @ 2024-07-11 09:28 红苹果学园 阅读(4) 评论(0) 推荐(0) 编辑
摘要: onSubmit={form.handleSubmit(onSubmit)} const onSubmit = (data: z.infer< typeof EmailPreferenceFormSchema>) => { const formData = new FormData() formDa 阅读全文
posted @ 2024-07-11 09:21 红苹果学园 阅读(5) 评论(0) 推荐(0) 编辑