Monday, 8 May 2017

Twit.js Error: getaddrinfo ENOTFOUND

Hello I hope this isn't a duplicate but I couldn't find anything here that helped.

I'm running through a new course on EggHead - https://egghead.io/lessons/node-js-work-with-users-in-twit-js and I am still learning node so I am not very good with debugging it.

My code:

var Twit = require('twit');

var bot = new Twit({
  consumer_key: process.env.TWITTER_CONSUMER_KEY,
  consumer_secret: process.env.TWITTER_SECRET_CONSUMER_KEY,
  access_token: process.env.TWITTER_ACCESS_TOKEN,
  access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
  timeout_ms: 60*1000
});

bot.post('statuses/update', {status: 'hello world'},
  function(err, data, res){
    if (err) {
      console.log(err);
    } else {
      console.log(data.text + ' was tweeted.');
    }
  });

Gives me this response:

{ Error: getaddrinfo ENOTFOUND api.twitter.com api.twitter.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:73:26)
  code: null,
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'api.twitter.com',
  host: 'api.twitter.com',
  port: 443,
  statusCode: null,
  allErrors: [],
  twitterReply: '' }

Any help would be greatly appreciated so I can hopefully build my first bot!

Thanks guys :)



via Niall Maher

No comments:

Post a Comment