Follow button PUT Problem

Once again, what you have pasted here is not runnable code. It’s very hard to fix code when the code isn’t at least 50% correct. Here you seem to have mixed JS and BASH…

It seems like your goal is to have some JS function that follows a user. In this case I’d recommend using our JS SDK, and then your function would look something like this:

function follow (channel) {
  var success = function () {
    // This will run if the follow succeeds
  }
  var failure = function () {
    // This will run if the follow fails
  }
  Twitch.getStatus(function (error, status) {
    if (error) return failure();
    if (!status.authenticated) return failure();
    
    Twitch.api({method: 'user'}, function (error, user) {
      if (error) return failure();

      Twitch.api({verb: 'PUT', method: 'users/' + user.name + '/follows/channels/' + channel}, function (error, response) {
        if (error) return failure();

        success();
      });
    });
}