# Pre-Script call API

**URL:** <https://community.postman.com/t/pre-script-call-api/36189>\
**Category:** Help Hub\
**Tags:** authentication, pre-request-script\
**Created:** [June 14, 2022, 8:24am UTC](https://community.postman.com/t/pre-script-call-api/36189 "2022-06-14T08:24:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlodellanno](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@carlodellanno](https://community.postman.com/u/carlodellanno)\
**Post date:** [June 14, 2022, 8:24am UTC](https://community.postman.com/t/pre-script-call-api/36189/1 "2022-06-14T08:24:49Z")

</div>

_My question_: Hi I have 2 API:

1. Autentication API in which i fill all variables in the test section, expecially a \_tokenAuth
2. an api that use that token

My purpose is that any time I run the second API, the Api 1 is run before to the token variables.  
Is possible to do this in Pre-Request Script? i didn’t find any function that allow me to call another API in the collection from there?

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 15, 2022, 8:55am UTC](https://community.postman.com/t/pre-script-call-api/36189/2 "2022-06-15T08:55:54Z")

</div>

Hi @carlodellanno

You could try using something like this in your pre-req;

```auto
const options = {
    url: 'https://randomuser.me/api/',
    method: 'GET',
    header: {
        'Content-Type': 'application/json'
    }
}

pm.sendRequest(options, (error, response) => {
    if (error) throw new Error(error);
});

```
