In Postman 10.7.1 for MacOS, pm.request.headers.each() fails when removing headers while iterating over them:
TypeError: Cannot read properties of undefined (reading 'value')
Using Request.forEachHeader() avoids that pitfall. Other options would be operating on pm.request.headers.members, or calling all() or map() before each(), since either would result in an independent list of headers.
For reference, Request.forEachHeader() internally calls pm.request.headers.all().each(callback).
Related Issue
62
Motivation and Context
Fixes a TypeError that breaks this collection.
How Has This Been Tested?
Manually and exhaustively with Postman.
Screenshots (if appropriate):
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
In Postman 10.7.1 for MacOS,
pm.request.headers.each()
fails when removing headers while iterating over them:Using Request.forEachHeader() avoids that pitfall. Other options would be operating on
pm.request.headers.members
, or callingall()
ormap()
beforeeach()
, since either would result in an independent list of headers.For reference, Request.forEachHeader() internally calls
pm.request.headers.all().each(callback)
.Related Issue
62
Motivation and Context
Fixes a TypeError that breaks this collection.
How Has This Been Tested?
Manually and exhaustively with Postman.
Screenshots (if appropriate):
Types of changes
Checklist: