handle-callback-err Expected error to be handled handle-callback-err Expected error to be handled vue.js vue.js

handle-callback-err Expected error to be handled


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.


Following are the things which have worked so far, from the help of comments:

if I put an if condition like following, error does not come:

error => {  if (error) {    console.log('Inside error, fetching product line items failed')    router.push({path: '/'})  }}

If I don't want to change the code, putting following will suppress the error completely:

/* eslint handle-callback-err: "warn" */

Looking forward to any better suggestions.