Skip to content

Async/Await

Await#

Database functions which provide the result to a callback also support the await keyboard. The script will basically pause until the database returned the result. The function in which you use await must be marked async. An example:

async function onUpdated() {
    // The old way using a callback
    DB.loadplayer(1, player => {
        echo('callback: ' + player.name);
    });

    // New way using await
    const player = await DB.loadplayer(1);
    echo('await: ' + player.name);
}