情境
route main內執行 child()
child為非同步
非同步的child function可以是
1.以async宣告
const asyncFun = async(res) => {
await sleep(2000)
const result = JSON.parse(body)
return result
}
2.以Promise宣告
const promiseFun = (res) => {
return new Promise((resolve, reject) => {
try {
const result = JSON.parse(body)
resolve(result)
} catch (e) {
reject(e)
}
})
}
如果child function內沒有使用try catch包裹




