# Global pre-request functions with pm.sendRequest do not wait for callback execution

**URL:** <https://community.postman.com/t/global-pre-request-functions-with-pm-sendrequest-do-not-wait-for-callback-execution/33036>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [February 28, 2022, 5:52pm UTC](https://community.postman.com/t/global-pre-request-functions-with-pm-sendrequest-do-not-wait-for-callback-execution/33036 "2022-02-28T17:52:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tha-dude](https://avatars.discourse-cdn.com/v4/letter/t/ac8455/32.png) [@tha-dude](https://community.postman.com/u/tha-dude)\
**Post date:** [February 28, 2022, 5:52pm UTC](https://community.postman.com/t/global-pre-request-functions-with-pm-sendrequest-do-not-wait-for-callback-execution/33036/1 "2022-02-28T17:52:17Z")

</div>

Hello,

I define the following **collection-level** pre-request script to be re-used by my collection’s requests:

```auto
utils = {
    testAsync : function() {
        pm.sendRequest(
            {url : 'https://www.google.com'}, // URL set to Google for testing
            (error, response) => {
                console.log(response)
            })
        console.log("Exiting.")
    }
}

```

However, when calling `utils.testAsync()` in a pre-request script of any of my collection’s requests Postman does not wait for the callback to be executed before proceeding to the actual request. What would I need to modify to fix this?

The way of making code globally accessible is based on [this answer](https://community.postman.com/t/global-functions-via-collection-level-folder/5927/11) on the forum.

Thank you

/David
