Tag: 方法链接

在Promise链中提取函数

我想通过提取出一些function来重构Promise链。 目前我有 const getData = (uuid) => { return new Promise((resolve) => { fetch( // go fetch stuff ) .then((response) => { if (!response.ok) { return resolve(false); } return response; }) .then(fetchres.json) .then(response => { // Do more stuff that requires resolves that I will also want to refactor }) .catch(err => { console.log(err); resolve(false); […]