Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-cn]: sync the translation of the "How to use promises" guide #19573

Merged
merged 7 commits into from
Apr 22, 2024
Prev Previous commit
Update index.md
  • Loading branch information
yin1999 authored Apr 22, 2024
commit 66a73cda4625b75c0e93a96acc0741680c93aeda
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fetchPromise
});
```

不必在第一个 `then()` 的处理程序中调用第二个 `then()`,我们可以直接*返回* `json()` 返回的 Promise,并在该返回值上调用第二个 "then()"。这被称为 **Promise 链**,意味着当我们需要连续进行异步函数调用时,我们就可以避免不断嵌套带来的缩进增加。
不必在第一个 `then()` 的处理程序中调用第二个 `then()`,我们可以直接*返回* `json()` 返回的 Promise,并在该返回值上调用第二个 `then()`。这被称为 **Promise 链**,意味着当我们需要连续进行异步函数调用时,我们就可以避免不断嵌套带来的缩进增加。

在进入下一步之前,还有一件事要补充:我们需要在尝试读取请求之前检查服务器是否接受并处理了该请求。我们将通过检查响应中的状态码来做到这一点,如果状态码不是“OK”,就抛出一个错误:

Expand Down