# Trying to prevent 302 redirect when loading script via eval

**URL:** <https://community.postman.com/t/trying-to-prevent-302-redirect-when-loading-script-via-eval/35017>\
**Category:** Help Hub\
**Tags:** pmsendrequest, eval, pre-request-script\
**Created:** [May 4, 2022, 8:32pm UTC](https://community.postman.com/t/trying-to-prevent-302-redirect-when-loading-script-via-eval/35017 "2022-05-04T20:32:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lampei](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/lampei/32/11897_2.png) [@Lampei](https://community.postman.com/u/Lampei)\
**Post date:** [May 4, 2022, 8:32pm UTC](https://community.postman.com/t/trying-to-prevent-302-redirect-when-loading-script-via-eval/35017/1 "2022-05-04T20:32:00Z")

</div>

In my request, I load, via a globals variable, some javascript and do an eval on it so I can call it and set up my tests (rather than trying to include a bunch of requests from other collections and having to maintain all of those requests).

I have my request set up (under settings), in postman, to ignore 302 redirects. I have found that when doing a “pm.sendRequest()” from within the "eval"d code in the pre-request script, that the pm object does not abide by the setting for the request (to ignore redirects) and will continue to accept the 302 and follow it. However, if I am in the request itself (the actual running of the request), then the 302-redirect _is_ ignored correctly.

Does anyone know of any way to modify the pm object itself within the eval’d script to force it to _also_ ignore the 302 redirect? I even tried passing in the pm object into my eval’d script to see if it was different in some way, but that did not work either.

---

<div class="post-metadata">

**Author:** ![Lampei](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/lampei/32/11897_2.png) [@Lampei](https://community.postman.com/u/Lampei)\
**Post date:** [May 5, 2022, 1:45pm UTC](https://community.postman.com/t/trying-to-prevent-302-redirect-when-loading-script-via-eval/35017/2 "2022-05-05T13:45:33Z")

</div>

I know everyone likes a follow up 🙂

So I tried running my collection via newman passing in `--ignore-redirects` and lo-and-behold, it works or at least agrees to _not_ follow redirects. I’ll be using this via CI/CD pipelines, so while it’s a little more difficult using the UI to do this, there is at least a work around for it.

However, this would be nice to be able to make the pm object configurable within the pm.sendRequest (maybe an override config) right off the bat (pre-request scripts also) rather than the settings only happening during the actual request itself as right now, running it via newman, I am preventing it following 302s for the **entire** collection run vs. for a specific request.
