guilhermefarias / instagram-api

:camera: New Instagram API 2016+
MIT License
53 stars 11 forks source link

SyntaxError: Unexpected token < in JSON at position 0(…) #8

Open zskynar opened 7 years ago

zskynar commented 7 years ago

When I use userSelfMedia() it comes back correct and I get the correct info but when I try to call a specific user it comes back..


SyntaxError: Unexpected token < in JSON at position 0( at Object.parse (native) at IncomingMessage. (/node_modules/instagram-api/lib/instagram.js:71:20) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:973:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)).


Is there something I'm doing wrong?

Doesnt Work instagramAPI.userMedia('user_id').then(function(result) { console.log(result.data); console.log(result.limit); console.log(result.remaining); }, function(err){ console.log(err); // error info }); }

Works instagramAPI.userSelfMedia('user_id').then(function(result) { console.log(result.data); console.log(result.limit); console.log(result.remaining); }, function(err){ console.log(err); // error info }); }

mkral commented 7 years ago

Are you actually sending the user_id in instagramAPI.userMedia ? instagramAPI.userSelfMedia probably works because it doesn't need a user_id, it uses the userID of who created the accessToken / makes the request.

You need to send which user to grab in the first request like: instagramAPI.userMedia('5482639').then...