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