The point is that Bubble runs your code in a synchronous way.
Any code that is asynchronous must be inside context.async or it will not be handled by bubble’s logic.
It doesn’t matter if you use async/await or then/catch.
Example with async/await:
const result = context.async(async (callback) => {
try {
const result = await doStuff();
callback(null, result);
} catch (error) {
callback(error);
}
});
Example with then/catch:
const result = context.async((callback) => {
doStuff()
.then((result) => {
callback(null, result);
})
.catch((error) => {
callback(error);
});
});