ciaranj / node-oauth

OAuth wrapper for node.js
MIT License
2.44k stars 660 forks source link

Error: socket hang up #346

Open lucypoly opened 6 years ago

lucypoly commented 6 years ago

Hi! I'am trying to use Twitter api. const OAuth = require('OAuth'); const oauth = new OAuth.OAuth( 'https://api.twitter.com/oauth/request_token', 'https://api.twitter.com/oauth/access_token', '...', '...', '1.0A', null, 'HMAC-SHA1' );

Here is my request: oauth.post( constants.BASE + 'collections/create.json?name=' + name, constants.TOKEN, constants.SECRET, (e, data, response) => { console.log(JSON.parse(data)); });

But I received _throw er; // Unhandled 'error' event Error: socket hang up at createHangUpError (_http_client.js:331:15)

Instead oauth.get( constants.BASE + 'search/tweets.json?q=' + id + '&count=10', constants.TOKEN, constants.SECRET, (e, data, response) => { console.log(JSON.parse(data)); }); works fine!