Cypress on headless mode not able to resolve promises through await calls

I can run following code in UI mode(headed) successfully. But it is failed and stuck when running headless mode using cypress. I tried different approaches to find a solution. but unfortunately couldn’t.

function makeRequest(requestOptions) {
return new Promise((resolve, reject) => {
try {
cy.request(requestOptions.url, requestOptions).then(resolve)
} catch (error) {
reject(error)
}
})
}

//Call method
await makeRequest()

Hello, I don’t much about Cypress, what is it a front end library?

Here is an article on Stack Overflow with similar issues it seems that there is probably a time out thing going on and is usually the case when it works one way but not the other’s.