小编ash*_*shr的帖子

ExpressJS 后端将请求放入队列

我有客户端发送要由服务器执行的任务,但这些请求应该像队列一样处理。知道我该怎么做吗?谢谢。

    express.Router().post('/tasks', function(req, res){
      //This is the task to perform. While being performed, another user
      //might send a request AND should only be processed when this is done.
      //This should also flag the pending task if it is completed.

      Promise.resolve(req.body)
      .then(function() {
      //..
      })
      .catch(function(error) {
        //....
      })

    })
Run Code Online (Sandbox Code Playgroud)

node.js promise express bluebird

5
推荐指数
1
解决办法
2489
查看次数

标签 统计

bluebird ×1

express ×1

node.js ×1

promise ×1