SyntaxError: Unexpected token robot.http when create new js to http request
ivanmpk opened this issue · comments
Hi, I write hubot script in javascript.
I want to create a hubot function to send post http to a webhook.
module.exports = (robot) => {
robot.respond(/resume (.*)/i, (res) => {
text = res.match[1]
data = JSON.stringify({ json: '{"id": ${text}
}'})
robot.http("https://stackstorm/api/v1/webhooks/resume_workflow")
.header('Content-Type', 'application/json')
.header('PRIVATE-TOKEN', 'xxxxxx')
.post(data) (err, res, body) =>
if err
res.send "Encountered an error :( #{err}"
return
})
}
But when run hubot I get the next message:
[Fri Nov 23 2018 11:35:33 GMT-0300 (-03)] ERROR Unable to load /home/ivan/hubot-rocketchat-boilerplate/scripts/resume: /home/ivan/hubot-rocketchat-boilerplate/scripts/resume.js:5
robot.http("https://stackstorm/api/v1/webhooks/resume_workflow")
^
SyntaxError: Unexpected token .
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (/home/ivan/hubot-rocketchat-boilerplate/node_modules/coffeescript/lib/coffeescript/register.js:53:36)