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

190
Views
Build array dynamically with JavaScript/Postman

Looking to create a JSON response body with JavaScript/Postman as a pre-request script with some dynamic variables. The issue I'm having is dynamically generating arrays inside the array. The data I'm receving is a CSV file so the value is like so Value1|Value2 and I need to separate the values from the pipe separator and pushing them into their own category array

Using the CSV value from the above example the output should be like this:

{
"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
]
}

I tried something like this

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

Trying to push the above into the categories array "categories":[]

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

0

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

returns an array strings to catNum.

Do this rather

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!