0

I'm using Bitly api to shorten links: http://dev.bitly.com/links.html#v3_shorten But then in the console log im getting an Error...

var Bitly = require('bitly');


  var bitly = new Bitly('key');

module.exports = function(req, res) {
  var term = req.query.text;
  handleSearchString(term, req, res);
};


function handleSearchString(term, req, res) {

  var response;
  try {

    response = sync.await(request({
      url: 'https://api-ssl.bitly.com/v3/link/shorten',
      qs: {
        //link: term,
        'access_token': key,
        'longUrl': term,
      },

      timeout: 15 * 1000
    }, sync.defer()));
  } catch (e) {
    res.status(500).send('\nError!\n');
    return;
  }
            var html = '<p> ' + response + '  </p>';
            res.json([{
             body: html
      }]);

};

Console.log outputs Error!,

ttt
  • 69
  • 2
  • 8

0 Answers0