2017-06-07 11 views
0

私は解決できないような問題があります。なぜなら、この特定のシナリオでなぜそれが発生しているのかほとんど知らないからです。ここ は誤りです:TypeError:未定義のプロパティ 'prototype'を読み取ることができません

const Twit = require('twit'), 
    config = require('./config'), 
    init = new Twit(config); 

function Twitter(twitter) { 
    this.twitter = twitter 
} 

Twitter.prototype.followers = function(params) { 
    this.twitter.get('followers/list', params, (err, data) => { 
     if (!err) 
      data.users.forEach(user => console.log(data)) 
    }) 
}; 

var bot = Twitter(init); 

bot.followers({ screen_name: 'myscreenname'}) 

母:

TypeError: Cannot read property 'followers' of undefined 
    at Object.<anonymous> (C:\Users\username\Documents\My Lib\bot\src\bot.js:15:4) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.runMain (module.js:604:10) 
    at run (bootstrap_node.js:393:7) 
    at startup (bootstrap_node.js:150:9) 
    at bootstrap_node.js:508:3 

、ここでは、コードは次のようになります。私はほとんどそれが愚かな間違いであると確信しています。私はソースを見つけることができないようです。 何か助力があり、感謝します。

答えて

0

newというキーワードを忘れました。試してみよう:

var bot = new Twitter(init); 
関連する問題