title: How to make a URL Shortener with the Bitly API with JavaScript JQuery?
body: <p>I'm trying to make a URL Shortener tool for my web application using the Bitly API.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/1771397/jquery-on-the-fly-url-shortener/22064069#22064069">an SO thread here</a> and saw what seemed to be simple enough jQuery solution.</p>
  
  <pre><code>getShortUrl: function(url, callback){
     var accessToken = //My access token, I've signed up at the site
     var url = 'https://api-ssl.bitly.com/v3/shorten?access_token=' + accessToken + '&amp;longUrl=' + encodeURIComponent(url);
  
  $.getJSON(
      url,
      {},
      function(response)
      {
          if(callback)
              callback(response.data.url);
      }
  );
  },
  
  alert(getShortUrl("https://stackoverflow.com/search?q=URL+Shortener+JavaScript"))
  </code></pre>
  
  <p>I'm testing this out in chromium dev tools. The code doesn't error but the alert always comes out as undefined. </p>