Cant make work my follow button JS :<

Hello, im working on a website and trying to make a follow button for twitch, im reading about the Twitch api but i cant make work my button, it makes the same error always

[Twitch] API Error: Not Found; USER is not following CHANNEL

$('#follow').click(function() {
  Twitch.api({method: 'user'}, function (error, user) {
    Twitch.api({verb: 'PUT', method: 'users/' + user.name + '/follows/channels/CHANNEL' }, function (error, response) {
    });
  });
})

I already log made the scope user_follows_edit etc

Are you using the CDN version of the JS SDK? That one is old and doesn’t support verb, so the browser is actually sending a GET to the API, which results in 404 for not following. You should use the up-to-date version on GitHub.

yeah ty! i did !!!

Sorry I can’t really help
so i put the word out for you on my twitter fermin in hopes that you would help me I know very little coding and I was trying to achieve the very same thing as you and have been doing research on the API but just keep getting uri and pram issues so if you could be so kind as to help explain how all the peace fit together to me I would be great full just want to have button on my HTML site
Why does it have to be so tuff

yeah sure, i just downloaded the js file to call it

< script src=“js/twitch.min.js”> < /script> u know xD

then just did the same as the example of twitch gave

$(function() {
Twitch.init({clientId: CLIENT_ID}, function(error, status) {
if (status.authenticated) {

  Twitch.api({method: 'user'}, function (error, user) {
    Twitch.api({verb: 'PUT', method: 'users/' + user.name + '/follows/channels/CHANNEL' }, function (error, response) {
    });
  });
      $('.status input').val('Logged in! Allowed scope: ' + status.scope);
      $('.authenticated').removeClass('hidden');
    } else {
      $('.status input').val('Not Logged in! Better connect with Twitch!');
      $('.authenticate').removeClass('hidden');
    }
  });

$(’.twitch-connect’).click(function() {
Twitch.login({
scope: [‘user_follows_edit’, ‘user_read’, ‘channel_read’]
});
})
});

hope it helps u

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.