I want to convert javascript code so that it works in postman

You can’t update the response through the pm.response function. It’s static.

What you can do, is parse the response into a variable and then update that variable.

You’ve already parsed the response to “responseData”, so you should just be able to loop though that. You don’t really need the function.

Have a look at the following topic which has an example of looping through and updating the response info. You can include your working IF statement into the mix,

Base 64 decoding in API response - :person_raising_hand: Help - Postman Community