I have a server.js file in which I have:
const express = require('express');
const app = express();
let driver;
(async () => {
try {
driver = await someAsyncFunction();
} catch (err) {
console.log(err);
}
})();
const port = process.env.PORT;
app.listen(port, () => {
console.log(`Server started on port ${port}.`);
});
module.exports = {
app,
driver,
};
However, the value of driver is undefined outside of the async function. How can I correctly assign a value to driver outside of the async function?