SImon Haddad
SImon Haddad

Reputation: 842

Eslint error when using the for in loop how to restructure

I am getting iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations error when using the following line of code

 const errors = {};
      for (const i of err.inner) {
        errors[i.path] = i.message;
      }

How can I restructure the code to remove this error Thanks

Upvotes: 2

Views: 1983

Answers (1)

Bassem
Bassem

Reputation: 4050

Try this:

let errors = {};

err.inner.forEach(item => {
   errors[item.path] =  item.message;
});

Upvotes: 1

Related Questions