We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
如下代码:
getMessage = () => { return new Promise((resolve,reject) => { setTimeout(() => { //resolve('1'); reject(new Error('error')); }, 300); }) } result = async() => { let res = await getMessage(); console.log(`res:${res}`); }
这个时候,我们执行result函数,会报错,因为promise走了catch流程,所以我们的result函数最好用try,catch包裹起来,如下代码:
result = async() => { try { let res = await getMessage(); console.log(`res:${res}`); } catch (error) { console.log(error) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
如下代码:
这个时候,我们执行result函数,会报错,因为promise走了catch流程,所以我们的result函数最好用try,catch包裹起来,如下代码:
The text was updated successfully, but these errors were encountered: