# Postman pre-request script does not set the variable for an access token

**URL:** <https://community.postman.com/t/postman-pre-request-script-does-not-set-the-variable-for-an-access-token/32562>\
**Category:** Help Hub\
**Tags:** authentication, pre-request-script\
**Created:** [February 14, 2022, 9:50am UTC](https://community.postman.com/t/postman-pre-request-script-does-not-set-the-variable-for-an-access-token/32562 "2022-02-14T09:50:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kevinc-postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevinc-postman/32/12774_2.png) [@kevinc-postman](https://community.postman.com/u/kevinc-postman)\
**Post date:** [February 14, 2022, 5:39pm UTC](https://community.postman.com/t/postman-pre-request-script-does-not-set-the-variable-for-an-access-token/32562/2 "2022-02-14T17:39:46Z")

</div>

Hey there! First, I’d like to welcome you to the Postman community and congrats on your first post! 🎊

So the issue that you are most likely having here is that `pm.sendRequest` is an [asynchronous](https://blog.postman.com/send-asynchronous-requests-with-postmans-pm-api/) function. This means that the code runs but is not completed before going on to the next line in your pre-request script. In other words, you are making the post request and that code is executing, however it is happening after the rest of your code that depends on a successful auth.

Here is one solution that I’ve used in the past to acomplish what you’re trying to do. Hope it helps! 😄

> [@Async Operations!](https://community.postman.com/t/async-operations/24314):
>
> I was working with a colleague and we were trying to achieve something by chaining multiple requests as a pre-step before the actual request happened. Use case: We wanted to call 3-4 specific endpoints in a specific order and gather all the required data before the actual request was sent out. One way was to do it by creating multiple requests and using the collection runner. But the other way was to make use of pm.sendRequest, however, there’s no guarantee in which order multiple of pm.sendR…

---

_[View the full topic](https://community.postman.com/t/postman-pre-request-script-does-not-set-the-variable-for-an-access-token/32562)._
