我正在尝试使用fetch,如下所示
export function* loadData() {
console.log("Saga: Loading Data...");
try {
const response = yield call(request, requestURL,
{ method: 'GET', credentials: 'include', headers: {
'Content-Type': 'application/json', } });
// Nothing past this point is ever touched
if (response.success) {
console.log("SUCCESS!!!!");
...
export default function request(url, options) {
return fetch(url, options)
.then(checkStatus)
.then(parseJSON);
}
CheckStatus确认数据的成功状态
function parseJSON(response) {
if (response.status === 204 || response.status === 205) {
return null;
}
var responseClone = response.clone();
console.log(responseClone.json());
return response.json();
}
没有足够的代表发布克隆输出的屏幕截图,但基本上是chrome dev输出
SAGA: Loading Data...
[[PromiseStatus]]:"resolved"
[[PromiseValue]]:Object
该对象包含我需要的所有数据,代码不会继续通过该响应调用。