Return result from a javascript callback

node v0.12.18
version: 1.0.0
endpointsharetweet
var Bypasser = require('node-bypasser'); var URI = require('urijs'); var data = 'multiple urls : http://example.com/foo http://example.com/bar'; var result = URI.withinString(data, function(url) { var unshortenedUrl = null; var w = new Bypasser(url); w.decrypt(function(err, res) { // How can I return res ? unshortenedUrl = res; }); // I know the w.descrypt function is a asynchronous function // so unshortenedUrl = null return unshortenedUrl; });
Loading…

no comments

    sign in to comment