postmanpostman-flows

How to map/manipulate data in Postman Flows


I've tried to transform data from API response in Postman Flows evaluate block using Postman FQL but unable to make it work. Here my script written in API tests

places.map(place => {
  return {
    id: place['id'], 
    dt: Object.assign({a: 1}, place['data'])
 }
})

The code is straight forward, if the place data is null or missing a, append that field to the dt.

I am able to get the desired field in Postman evaluate but don't know how to append a to the dt

body.{
  'id':id, 
  'dt': data
}

Flow evaluate

How can I do it in Postman Flows' evaluate?


Solution

  • I was hoping to have access to similar object manipulation methods in FQL as we have in JavaScript, such as merging objects and adding properties. Instead, I have to manually combine objects, which can be challenging as I need to be aware of the number of properties an object has and ensure that properties with null values do not cause any issues.

    Flow