await-add-catch-loader
v1.0.5
Published
add catch for await
Downloads
2
Readme
一个自动为await添加catch的loader
Usage
//webpack.config.js
module.exports = {
//...
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/, //刨除哪个文件里的js文件
include: path.resolve(__dirname, "./src"),
use: [
{loader: "babel-loader"},
{
loader: 'await-add-catch-loader',
options: {
needReturn: true,
consoleError: true,
customizeCatchCode: "//please input you want to do",
},
},
],
},
],
},
}
// needReturn: true,
const fn = async() => {
const { data } = await po()
}
//build
const fn = async() => {
const { data } = await po().catch(err=>{ return {} });
}
// consoleError: true,
const fn = async() => {
const { data } = await po()
}
//build
const fn = async() => {
const { data } = await po().catch(err=>{ console.log(err) });
}
// customizeCatchCode: "please input you want to do;",
const fn = async() => {
const { data } = await po()
}
//build
const fn = async() => {
const { data } = await po().catch(err=>{ please input you want to do });
}