Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Cree un objeto para acceder a la clave y el valor de otro objeto

Recibo los siguientes datos en mi respuesta en api

 email: Array(1) 0: "The email has already been taken." length: 1 __ob__: Observer {value: Array(1), dep: Dep, vmCount: 0} [[Prototype]]: Array first_name: Array(1) 0: "The first name field is required." length: 1 __ob__: Observer {value: Array(1), dep: Dep, vmCount: 0} [[Prototype]]: Array

¿Cómo podría crear un objeto así?

 errors = [{'email':"The email has already been taken."}]

Intenté algo como esto

 const object1 = {}; let object = this.registerErrors; for(var key in object){ object1 = Object.assign({key : object[key]}) } console.log(object1)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Prueba como el siguiente fragmento:

 const registerErrors = { email: ["The email has already been taken."], first_name: ["The first name field is required."] } let object1 = {}; let object = registerErrors; for(key in object){ object1[key] = object[key] } console.log(object1)

about 4 years ago · Juan Pablo Isaza Report

0

Prueba esto

 // 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);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!