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

188
Views
Cree una matriz dinámicamente con JavaScript/Postman

Buscando crear un cuerpo de respuesta JSON con JavaScript/Postman como un script de solicitud previa con algunas variables dinámicas. El problema que tengo es generar matrices dinámicamente dentro de la matriz. Los datos que recibo son un archivo CSV, por lo que el valor es así Value1|Value2 y necesito separar los valores del separador de tuberías y colocarlos en su propia matriz de categorías.

Usando el valor CSV del ejemplo anterior, la salida debería ser así:

 { "id": 1, "store": 1, "title": custom_title, "url": custom_url, "content": content, "categories":[ { "id":1, "name":"Value1", "type":"Type" }, { "id":1, "name":"Value2", "type":"Type" }, //add more if needed dynamically ] }

Intenté algo como esto

 var catNum = "Blog|Healthy".split('|'); catNum.forEach((value, name) => bodyRequest.categories.push({ "id": 1, "type": "Category", "name": value.toLowerCase(), "blog_category_path": value }));

Intentando insertar lo anterior en la matriz de "categories":[]

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

0

var catNum = "Blog|Healthy".split('|');

devuelve una matriz de cadenas a catNum.

haz esto mas bien

 catNum.forEach(value => bodyRequest.categories.push({ "id": 1, "type": "Category", "name": value.toLowerCase(), "blog_category_path": value }));
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!