doc/issue-service/sample.js
function connect (conf) {
  // Instantiating API client, this is the one that will be passed to other methods
  var client = new Client();

  if (conf["my-host.token"]) {
    // Authorize client
    client.setToken(conf["my-host.token"]);
    // Check token…
    return checkToken(client)
      .then(null, function () {
        // …and create a new one if it failed
        console.error("Existing token is invalid");
        return createToken(client);
      });
  } else {
    // No token found: create new one
    return createToken(client);
  }
}
function connect (conf) {
  // Instantiating API client, this is the one that will be passed to other methods
  var client = new Client();

  if (conf["my-host.token"]) {
    // Authorize client
    client.setToken(conf["my-host.token"]);
    // Check token…
    return checkToken(client)
      .then(null, function () {
        // …and create a new one if it failed
        console.error("Existing token is invalid");
        return createToken(client);
      });
  } else {
    // No token found: create new one
    return createToken(client);
  }
}
function connect ( conf ) { // Instantiating API client, this is the one that will be passed to other methods var client = new Client ( ) ; if ( conf [ "my-host.token" ] ) { // Authorize client client . setToken ( conf [ "my-host.token" ] ) ; // Check token… return checkToken ( client ) . then ( null , function ( ) { // …and create a new one if it failed console . error ( "Existing token is invalid" ) ; return createToken ( client ) ; } ) ; } else { // No token found: create new one return createToken ( client ) ; } }
Assuming client.setToken sets authorization token for next calls
Assuming client . setToken sets authorization token for next calls