Skip to content
Advertisement

How do I fix “Identifier directly after number” error

could anyone tell me what’s wrong with this code and how to fix it? Any help would be appreciated, thanks. The error is: “null – parsing error: Identifier direcly after number”.

/**
  * Authorize Google Youtube API.
  */
  var auth = function(immediate, callback) {
    gapi.client.setApiKey(AIzaSyB7xh-QBr-4kpV7RMlYMZ_aUQB5FmfMRLs);
    gapi.auth.authorize({
      client_id: 1077089514511-s11blgkep9up7cu7hnq0c84t12ba8ihe.apps.googleusercontent.com,
      scope: https://www.googleapis.com/auth/youtube,
      immediate: immediate
    }, callback);
  };

Here’s the other code with the error “ChannelId already defined”:

var getChannelURI = function() {
    var re = /youtube.com/(user|channel|c)/([^/]+)/,
        m;
    var channelId = "$"('meta[itemprop=channelId]').attr('content');
    debug(channelId);
    if (channelId) {
      return channelId;
    }
    var channelId = "$"('meta[property="og:url"]').attr('content');
    if (channelId) {
      return channelId.match(re)[2];
    }
  };

Advertisement

Answer

In JavaScript objects, string values must be wrapped with quotation marks, you can use "string" or 'string'.

This is what your code should look like.

/**
 * Authorize Google Youtube API.
 */
var auth = function (immediate, callback) {
  gapi.client.setApiKey("AIzaSyB7xh-QBr-4kpV7RMlYMZ_aUQB5FmfMRLs");
  gapi.auth.authorize(
    {
      client_id:
        "1077089514511-s11blgkep9up7cu7hnq0c84t12ba8ihe.apps.googleusercontent.com",
      scope: "https://www.googleapis.com/auth/youtube",
      immediate: immediate,
    },
    callback
  );
};

More on JavaScript objects

Advertisement