Advertisement
digininja

CoffeeScript undefined is not a function

Sep 24th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CoffeeScript experts, what is wrong with the script below to cause this error?
  2.  
  3.  
  4. [Tue Sep 20 2016 06:44:41 GMT+0000 (UTC)] ERROR TypeError: undefined is not a function
  5.   at /home/hubot/scripts/hack.coffee:16:13, <js>:11:20
  6.  
  7.  
  8.  
  9.   9     robot.respond /check (.*)/i, (res) ->
  10.  10         host = res.match[1]
  11.  11         robot.http("http://robin.home/check?#{host}").get() (err, res, body) ->
  12.  12             if err
  13.  13                 res.send "Encountered an error :( #{err}"
  14.  14                 return
  15.  15
  16.  16             res.send "Got back "
  17.  17
  18.  
  19. It is based on the code from here if it helps:
  20.  
  21. https://hubot.github.com/docs/scripting/#making-http-calls
  22.  
  23. ----------
  24.  
  25. Fixed it, the variable res was being reused and so stopped being an instance of Response and became an instance of http.ServerResponse instead. I've raised an issue in Github about this to hopefully update the docs and improve clarity.
  26.  
  27. https://github.com/github/hubot/issues/1241
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement