

APIを叩いて配列にpushするというコードを書きました。

[code]

    lodash = require('lodash')
    
    module.exports = (robot) ->
    
      URL = "http://..."
      envelope = room: "room"
    
      request = robot.http("#{URL}/api/...")
                     .get()
    
      request (err, res, body) ->
        json = JSON.parse body
    
        row_users = []
        for obj in json['users']
          name = obj['name']
          row_users.push(name)
    
        users = robot.brain.get(KEY) ? []
        diff = lodash.difference(row_users, users)
    
        for name in diff
          robot.send envelope, "ユーザーの登録があります #{name}" 
    
[/code]

エラー文

[code]

    ERROR TypeError: Object #<Object> has no method 'replace'
    [Sun Jan 24 2016 14:02:00 GMT+0000 (UTC)] ERROR TypeError: Object #<Object> has no method 'replace'
    2016-01-24T14:02:00.004985+00:00 app[web.1]:   at SlackBot.send (/app/node_modules/hubot-slack/src/slack.coffee:229:47, <js>:278:19)
    2016-01-24T14:02:00.004986+00:00 app[web.1]:   at runAdapterSend (/app/node_modules/hubot/src/response.coffee:82:34, <js>:87:50)
    2016-01-24T14:02:00.004987+00:00 app[web.1]:   at allDone (/app/node_modules/hubot/src/middleware.coffee:44:37, <js>:34:16)
    2016-01-24T14:02:00.004988+00:00 app[web.1]:   at /app/node_modules/hubot/node_modules/async/lib/async.js:274:13
    
[/code]

hubotとslackの連携を試みています。  
配列をString型に置き換えれてないのが原因でしょうか。

よろしくお願いいたします。


CC BY-SA 3.0
2016-01-24T11:24:26.007
21261
2016-01-25T14:15:43.757
2016-01-25T14:15:43.757
14020
14020
question
javascript coffeescript
hubotとslackの連携でのエラー　JSON ERROR TypeError: Object #<Object> has no method 'replace'