當我執行以下操作時:
import { useGetPostQuery } from "./store/postApi";
export function App() {
const { data, isLoading, isFetching, isError, error } = useGetPostQuery(1);
if (isError)
return (
<div>
{error.status}
<br />
{error.data}
</div>
);
if (isLoading) return <div>loading...</div>;
return <div className={isFetching ? "posts--disabled" : ""}>{data}</div>;
}
我收到一個錯誤:
PARSING_ERROR 你好世界
基本上,我只想從服務器回傳字串 HELLO WORLD。我應該如何避免決議錯誤?
可以在此處找到該示例的代碼沙箱。
uj5u.com熱心網友回復:
我猜它需要一個 JSON 回應。
我的 PHP 腳本:
echo json_encode(array("data"=>file_get_contents("data".$_GET["id"].".txt")));
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/497299.html
標籤:解析 还原 反应还原 获取 API redux 工具包
上一篇:不是一開始就基于模式決議
