0

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?

Manh Le
  • 1,630
  • 16
  • 26
  • I have a question, I requested early access in today, how long takes a time to use it? – Bench Vue Jan 27 '23 at 20:21
  • @BenchVue Idk mate, just found it appear in my account at least a few months ago but didn't have time to try it. – Manh Le Jan 29 '23 at 03:51
  • 1
    Thanks you very much you are an early adopter. I think most people not yet available to test Flows. It will be quick to address a problem by your yourself. – Bench Vue Jan 29 '23 at 11:27
  • Thanks @BenchVue. I can finally achieve what I need, but not what I expect. Maybe Flows planned to improve in the future. Will post my solution below. – Manh Le Jan 30 '23 at 02:45

1 Answers1

0

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

Manh Le
  • 1,630
  • 16
  • 26