【发布时间】:2016-06-30 12:26:06
【问题描述】:
我正在研究@Dan Abramov 的flux-react-router-example,我在 Fetch API 代码中注意到 here:fetch API 有一个返回承诺,里面有一个嵌套的返回:
return fetch(url).then(response =>
response.json().then(json => {
const camelizedJson = camelizeKeys(json);
const nextPageUrl = getNextPageUrl(response) || undefined;
return {
...normalize(camelizedJson, schema),
nextPageUrl
};
})
);
我对这个嵌套返回感到困惑,为什么在这里使用它?为什么不直接返回 response.json()?
好像如果我做同样的事情,我会得到一个未定义的值
【问题讨论】:
标签: javascript ajax reactjs flux reactjs-flux