Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
Add a variable to a response path

I'm trying to add a variable into a path like this:

response.response.body.result.company.data.t${variable}.month_col_val[i]

I know it's wrong, yet I'm not being able to find if it's actually posible to do it and how to do it. My json file contains objects named t0, t1, t2... and so on inside data, so i'm trying to get an specific one by adding the variable value along the T

Variable is define outside the fuction and pass as a parameter.

for (let o = 0; o < 12; o++) {
                    cy.get($el).find('.month-data-cols').eq(o).invoke('text').then($text => {
                        let monthGross = $text
                        let monthGrossReq = response.response.body.result.company.data.t${variable}.month_col_val[o]
                        monthGross = monthGross.toString().replace(/,/g, '').trim();
                        expect(monthGross).to.include(monthGrossReq);
                    })
                };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try using square-bracket notation instead of dot-notation at that property

const data = response.response.body.result.company.data
const monthGrossReq = data[`t${variable}`].month_col_val[o]
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda