我正在尝试为 Slack 进行集成,查询服务器并向用户返回一些结果。搜索有时需要比 Slack 允许响应的窗口更长的时间,因此我需要立即返回状态 200。
我如何使用 lambda 函数来做到这一点?我尝试使用回调函数,然后将数据发送到另一个 lambda 服务,但原始函数等待它返回,这意味着我仍然被我正在查询的服务器阻止。
这是我正在处理的内容
var rp = require('request-promise');
exports.handler = (event, context, callback) =>{
//I wanted this to send back my STATUS 200 so the command wouldn't time out
callback(null, "Working...");
//I want this post to happen asynchronously so that slack gets the callback response while the search is happening
//but this still waits until the post comes back before resolving the callback
var options = {
method: 'POST',
uri: "https://url-to-other.service",
body:{ …Run Code Online (Sandbox Code Playgroud)