chenyaya-promise-catch-loader
v1.0.1
Published
this is loader to add catch after promise.then, the arrowFunction will use The Frist Expression of then.
Downloads
3
Readme
promise-catch-loader
this is loader to add catch after promise.then, the arrowFunction will use The Frist Expression of then.
just Like:
// before:
Promise.resolve('1').then(res => {
this.loading = false
this.handleClose()
})
// after
Promise.resolve('1').then(res => {
this.loading = false
this.handleClose()
}).catch(()=>{
this.loading = false
})
How to use
install
npm install chenyaya-promise-catch-loader -D
or
yarn add chenyaya-promise-catch-loader --save-d
Set Webpack Config
const path = require('path')
module.exports = {
entry:'./src/index.js',
output:{
filename:'bundle.js',
path:path.resolve(__dirname,'./dist')
},
module:{
rules:[
{
test:/\.js$/,
use:['chenyaya-promise-catch-loader']
}
]
}
}