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

544
Vistas
POSTMAN - Extract multiple values from a JSON response and store in a variable with comma separated

JSON Response as below:

{ "value":[ { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" } ] }

Tried below code snippet:

const responseBody = '{ "value":[ { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" } ] }';
var data = JSON.parse(responseBody);
const temp = [];
data.forEach(function(value, i){
if(data.value[i]){
temp[i] = data.value[i].email
}
});
var subscriptions = temp.join(",");
postman.setEnvironmentVariable("testData", temp);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

data is an object, not an array. It doesn't have a forEach method. You have to iterate over data.value:

const responseBody = '{ "value":[ { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" }, { "email": "xxx@xx.com" } ] }';
var data = JSON.parse(responseBody);
const temp = data.value.map(value => value?.email);
var subscriptions = temp.join(",");
console.log(subscriptions);
//postman.setEnvironmentVariable("testData", temp);

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