node.js - node request library return an error on api call -
i'm using bitly api shorten links: http://dev.bitly.com/links.html#v3_shorten in console log im getting 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!,
Comments
Post a Comment