const a = fetch('http://localhost:10003/api/sys_user/login', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: '1', password: '1' })
})
const b = fetch('http://localhost:10003/api/sys_user/login', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: '1', password: '1' })
})
Promise.pAll = function(arr) {
return new Promise((resolve, reject) => {
const result = []
for (p of arr) {
p.then(res => {
result.push(res)
if (result.length === arr.length) {
resolve(result)
}
}).catch(err => {
reject(err)
})
}
})
}
Promise.pAll([a, b]).then(res => {
console.log(res)
})
console