我是redux和reactjs的新手,我正在尝试将一些服务器端数据提取到我的代码中。
这是我的thunk fetch:
fetch(`/WebApp/Dashboard/CreateAlert`).then(response => {
console.log(response);
});
这是我在控制台中看到的:
在小提琴手中,我看到响应是“成功”的预期。
此回复是否有效,如何解析,我有点困惑,网上的信息很少。
修改:
我改为:
fetch(url).
then(response => response.json())
.then(json => {
console.log(json);
});
我收到了这个对象。现在,当我发送一个复杂类型(List)时,我看到了下面的文字:
答案 0 :(得分:1)
如果要解析json响应:
fetch(`/WebApp/Dashboard/CreateAlert`)
.then(response => response.json())
.then(json => {
console.log(json);
});
有关可用于解析响应正文的所有方法,请参阅https://developer.mozilla.org/en-US/docs/Web/API/Body。