[Vuejs]-Create an object to access the key and value from another object

0👍

Try this

// Assuming that your error response obj is like
const registerErrors = {
  email: ["The email has already been taken."],
  first_name: ["The first name field is required."]
}

let errors = {};
Object.keys(registerErrors).forEach(key => {
 errors[key]=registerErrors[key][0];
});
console.log(errors);

Leave a comment