# Calling a pm.sendrequest within a promise chain doesnt get executed

**URL:** <https://community.postman.com/t/calling-a-pm-sendrequest-within-a-promise-chain-doesnt-get-executed/17206>\
**Category:** Help Hub\
**Created:** [October 28, 2020, 9:41pm UTC](https://community.postman.com/t/calling-a-pm-sendrequest-within-a-promise-chain-doesnt-get-executed/17206 "2020-10-28T21:41:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasoncaunt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jasoncaunt/32/4763_2.png) [@jasoncaunt](https://community.postman.com/u/jasoncaunt)\
**Post date:** [October 28, 2020, 9:41pm UTC](https://community.postman.com/t/calling-a-pm-sendrequest-within-a-promise-chain-doesnt-get-executed/17206/1 "2020-10-28T21:41:56Z")

</div>

Calling a pm.sendrequest within a promise chain doesnt get executed.

The first pm.sendrequest works fine but none in the chain seem to execute.

Executing chain like:

globalMethods.execute\_method\_request.getBearerToken()  
.then((v) =\> { return globalMethods.execute\_method\_request.getRequest1(); })  
.then((v) =\> { return globalMethods.execute\_method\_request.getRequest2(); })  
.catch((v) =\> { console.log("ERROR: " + err) })

Each promise is like:

let getBearerToken = () =\> new Promise((resolve, reject) =\> {  
console.log("-------------------------------------- Bearer Token --------------------------------------")  
pm.sendRequest({  
url: BaseURL + “api/Token”,  
method: ‘POST’,  
header: {  
‘Content-Type’: ‘application/x-www-form-urlencoded’  
},  
body: {  
mode: ‘urlencoded’,  
urlencoded: [  
{ key: “grant\_type”, value: “password” },  
{ key: “username”, value: Username },  
{ key: “password”, value: Password }  
]  
}  
}, (err, response) =\> {  
if (err) {  
console.log('Error: ’ + err);  
return reject(err);  
}  
if (response.code === 200) {  
let responseData = response.json();  
var token = responseData.access\_token;  
pm.environment.set(‘bearer\_token’, token);  
console.log("Bearer Token: " + token)  
return resolve();  
}  
return reject(‘Response was not 200’);  
});  
});

If you substitute the following requests with code that doesn’t perform a pm.sendrequest then the promise chain executes as expected.

The code does work as it has been running fine all morning
