Coffeescript 正在从hubot http侦听器回调发送请求;TypeError:无法读取属性';在';“未定义”的定义;

Coffeescript 正在从hubot http侦听器回调发送请求;TypeError:无法读取属性';在';“未定义”的定义;,coffeescript,hubot,Coffeescript,Hubot,我在试图让我的hubot实例在http侦听器的回调中执行http请求时遇到问题。我猜它是在REQ/RES周期的中间,无法完成一个不同的请求。通常robot对象具有允许发送一个的http方法,但在我在线看到的其他hubot示例中,我不断得到“TypeError:Cannot read property'on'of undefined”,它们指的是响应对象的使用,但这只是聊天侦听器内部的情况,事实上,当我尝试使用响应对象时,它会抛出一个错误,“TypeError:res.http不是函数”。非常感谢

我在试图让我的hubot实例在http侦听器的回调中执行http请求时遇到问题。我猜它是在REQ/RES周期的中间,无法完成一个不同的请求。通常robot对象具有允许发送一个的http方法,但在我在线看到的其他hubot示例中,我不断得到“TypeError:Cannot read property'on'of undefined”,它们指的是响应对象的使用,但这只是聊天侦听器内部的情况,事实上,当我尝试使用响应对象时,它会抛出一个错误,“TypeError:res.http不是函数”。非常感谢您的帮助。谢谢

  robot.router.post '/gitlab-incoming', (req, res) ->
data = {
  "request_type": req.body.object_kind,
  "status": req.body.object_attributes.state,
  "project_name": req.body.object_attributes.source.name,
  "branch_name": req.body.object_attributes.source_branch,
  "job_name": 'review_stop',
  "team_name": process.env.GITLAB_TEAM_NAME,
  "gitlab_ci_token": process.env.GITLAB_CI_TOKEN,
  "action": 'play',
  "project_id": "#{process.env.GITLAB_TEAM_NAME}%2F#{req.body.object_attributes.source.name}"
}
if data['status'] == 'merged'
  robot.http("https://gitlab.com/api/v4/projects/#{data['project_id']}/jobs")
  .header('Accept', 'application/json')
  .header('PRIVATE-TOKEN', data['gitlab_ci_token'])
  .get() (err, http_res, body) ->
    if err
      res.send 'Sorry. Unable to fetch the list of jobs from Gitlab'
    job_found = false
    job_id = undefined