【文件属性】:
文件名称:node-catch-errors:高阶功能,可捕捉承诺中的错误
文件大小:5KB
文件格式:ZIP
更新时间:2021-05-01 18:36:36
promises node errors async catch
捕捉错误
由。
一种高级功能,可以从promise中捕获错误。
安装
安装套件
$ npm install --save catch-errors
用法
const fetch = require ( 'node-fetch' ) ;
const catchErrors = require ( 'catch-errors' ) ;
async function load ( username ) {
const response = await fetch ( `https://api.github.com/users/ ${ username } ` ) ;
const user = await response . json ( ) ;
console . log ( user . name ) ;
}
const wrappedLoad = catchErrors (
【文件预览】:
node-catch-errors-master
----.eslintrc(387B)
----package.json(866B)
----.prettierrc(53B)
----LICENSE(1KB)
----src()
--------index.js(146B)
----.gitignore(883B)
----CHANGELOG.md(270B)
----.npmrc(56B)
----README.md(1KB)
----.eslintignore(13B)
----.editorconfig(236B)
----.gitattributes(19B)