【问题标题】:Nodejs - Return response while sql is runningNodejs - 在sql运行时返回响应
【发布时间】:2022-12-04 13:43:33
【问题描述】:

I have a function that simply invokes another function that executes sql and returns a uuid. The idea is that - the sql is a long running task, and instead of making the user wait until the sql execution takes place, id like to send a uuid, with which they can make a subsequent request to fetch the results. Here is my code:

async getUUID() {
 await executeSql();
 let uuid = uuidv4();//being created using the library
 return uuid;
}

async executeSql() {
 //sql query stuff
}

However, I get the uuid only when the sql execution is complete. How can I make this more independent of the executeSql function?

    标签: node.js asynchronous async-await


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-25
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多