Promise.all 方法用于将多个 Promise 实例,包装成一个新的 Promise 实例。
<!doctype html>
<html>
<head>
</head>
<body>
<script>
const fetchRequest = (url) => {
return new Promise(async (resolve, reject) => {
let response = await fetch(url);
if (response.status === 200) {
let responseJson = await response.json();
resolve(responseJson);
} else {
reject(new Error('出错了'));
}
})
...