Skhmt / tapic

Twitch API & Chat. A javascript library for doing things with twitch chat, APIs, and pubsub. Can be used to make a HTML or Node.js bot. Or something.
MIT License
18 stars 5 forks source link

callback not defined (isSubscribing, isFollowing) #1

Closed JouanMarcel closed 8 years ago

JouanMarcel commented 8 years ago

Calling the function isSubscribing (or isFollowing) results in "tapic.js:374 Uncaught TypeError: callback is not a function" as callback is not defined.

Not using node.js; Chrome v51

Skhmt commented 8 years ago

Fixed the error in a newer version of TAPIC that will be uploaded likely within 24 hrs.

The error message you received is correct, but not useful. isSubscribing and isFollowing are asynchronous functions, so they need a callback function.

Example:

var folUser = 'skhmt';
var folTarget = 'letsmakefriends';
TAPIC.isFollowing( folUser, folTarget, function( res ) {
  if ( res.isFollowing ) console.log( folUser + ' has been following ' + folTarget + ' since: ' + res.dateFollowed );
  else console.log( folUser + ' is not following ' + folTarget + '.' );
} );