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

309
Views
How to convert a json response to array javascript

I have this json response from a api:

[
{
"obj_Id": 66,
"obj_Nombre": "mnu_mantenimiento_de_unidades",
"obj_Descripcion": "Menu de acceso a Mantenimiento de Unidades"
},
{
"obj_Id": 67,
"obj_Nombre": "mnu_vehiculos_en_reparacion",
"obj_Descripcion": "Menu de acceso a Reparacion de Unidades"
},
{
"obj_Id": 68,
"obj_Nombre": "mnu_RTO",
"obj_Descripcion": "Menu de acceso a RTO"
}
]   

I have this function to make the request and convert the response:

async obtenerPermisos() {
      var respuesta = "";
    
      var obj = {
        idUsuario: JSON.parse(sessionStorage.getItem("Codigo")),
        contraseña: this.passwordEncriptado,
      };

      this.url = this.urlBase + "usuario/obtenerPermisos";

      respuesta = await this.$http.post(this.url, obj).then((response) => {
        const respuesta1 = JSON.parse(respuesta);
        sessionStorage.setItem("Permisos", respuesta1);
        response.data;
      });

      console.log("Los permisos del usuario son: ");
      console.log(respuesta);
      console.log("El tipo de parametro es: " + typeof respuesta);

      
      sessionStorage.setItem("Permisos", respuesta);
      this.$router.push({ name: "sideBar" });
      location.reload();
    },

but i get this error:

enter image description here

how can i resolve it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The data being returned is not being passed to JSON.parse()

// Wrong implementation
const respuesta1 = JSON.parse(respuesta);

// Correct implementation
const respuesta1 = JSON.parse(response.data);
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!