Storing json response members to variable using destructuring assignment

Code play ground :

I love javascript for a reason ,

#Destructuringassignment #javascript

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. :heart:

Reasons to love #javascripts

you can use this in postman to store response members to a variable

eg:

to store name age job from a response like :

{

"name": "user",

"age" : 20,

"job" : "QA"

}

you just have to do is:

let { name,age,job} = pm.response.json()

console.log(name,age,job)

#javascriptframework #testautomationframework #automationtesting #testautomation #articles #postmanapi #apiautomation

2 Likes

This is really nice :slight_smile:

1 Like

Thanks Pranav :heart_eyes: it’s much cleaner easier to use