Skip to content
Discussion options

You must be logged in to vote

Promises are a basic JavaScript thing, that needs to be awaited:

// +server.js
export async function POST({ request }) {
    let file_name = await set_file();
    console.log(file_name)
}

async function set_file() {
    const date = new Date();
    var ms = date.getTime();
    return 'static/' + ms + '.png'
}

But since you do not do any async stuff in the set_file function, you can just omit the async from the function declaration.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@magic-thomas
Comment options

Answer selected by magic-thomas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants