i’m trying to create a streamers website with a lot of twitch functionality. One of these is having a follow button. Now it works as it seems but it’s generating an 404 error saying: [Twitch] Response Data: Object {error: “Not Found”, status: 404, message: “[user] is not following [channel]”}
I’m having trouble finding out where this error comes from.
The code i use is similar to something I found on this forum and I literally copied/pasted this code resulting in the same error.
$scope.follow = function() {
var success = function (response) { console.log("success: " + response) }
var failure = function (error) { console.log("error: " + error) };
Twitch.getStatus(function (error, status) {
if (error) return failure(error.message);
if (!status.authenticated) return failure(error.message);
Twitch.api({method: 'user'}, function (error, user) {
if (error) return failure(error.message);
Twitch.api({verb: 'PUT', method: 'users/' + user.name + '/follows/channels/' + channel}, function (error, response) {
if (error) return failure(error.message);
success(response);
});
});
});
}
Hope someone can help me out on this one!
EDIT:
the API can’t find the channel the user wants to follow
channel is just a variable i have set, it’s not generated anywhere. var channel = “channel_name”.
and let’s say this 404 you are talking about is what’s happening, it doesn’t make sense. $scope.follow gives a true or false. To get that statement i call upon a function which checks if the user is actually following the channel. This actually works fine, returns the right value every time. So basically this message you explained can’t actually occur because what the code above is doing is trying to unfollow [channel] that [user] is following in order to unfollow [channel] and vice versa
and the second reason it doesn’t make sense to me is you’re talking about a 404 while i’m getting a 401
for everyone else: if you’re looking for a follow button for your website. this should work for you keep in mind that this function uses some angular, can be easily replaced with other JS)