[英]redux-thunk fetch parse response
我是redux和reactjs的新手,正在嘗試將一些服務器端數據提取到我的代碼中。
這是我的笨拙抓取:
fetch(`/WebApp/Dashboard/CreateAlert`).then(response => {
console.log(response);
});
這是我在控制台中看到的:
在提琴手中,我看到的響應是預期的“成功”。
此響應是否有效以及如何解析?我有點困惑,在線信息很少。
編輯 :
我改為:
fetch(url).
then(response => response.json())
.then(json => {
console.log(json);
});
我收到了對象。 現在,當我發送一個復雜的類型(列表)時,我看到了下面的提示:
如果要解析json響應:
fetch(`/WebApp/Dashboard/CreateAlert`)
.then(response => response.json())
.then(json => {
console.log(json);
});
有關可用於解析響應正文的所有方法,請參見https://developer.mozilla.org/en-US/docs/Web/API/Body 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.