I have eslint
enabled in my vue webapp, I have following code:
myApi.get('products/12').then((prodResponse) => {
state.commit('ADD_PRODUCT', {product: prodResponse.data})
},
error => {
console.log('Inside error, fetching product line items failed')
router.push({path: '/'})
})
This is the error handling I want to do, still I get following error from the liner:
✘ http://eslint.org/docs/rules/handle-callback-err Expected error to be handled ~/vue/src/store/modules/myStore.js:97:9 error => {
I can add following comment to convert this into warning:
/* eslint handle-callback-err: "warn" */
But how do I suppress this completely or modify code, so that this error doesn't come.
Just had the same thing, and the warning message is misleading; it's actually because error
is not referenced in the code, not because it's not "handled".
Make sure you do something with error, such as a console.log()
or don't include it as an argument:
// do something with error:
error => {
console.log('Inside error, fetching product line items failed', error)
router.push({path: '/'})
}
// don't define argument:
() => {
console.log('Inside error, fetching product line items failed')
router.push({path: '/'})
}
try this:
error => {
console.log('Inside error, fetching product line items failed', error)
router.push({path: '/'})
}
if there is an error, you need to handle it in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With