node-osmosis
node-osmosis copied to clipboard
Return data?
Ok I am trying to run osmosis inside a loop as it relates to data in a csv. It's not huge data so not worried about optimization although any tips would be helpful. Pretty much just need to return results of osmosis data (singular piece of data) for each row in csv.... but I can't get osmosis to 'return' in a function.
function scrape(vin){ osmosis .get('http://www.xxxxxxxxxx.com/searchnew.aspx?sv=~'+ vin) .find('.hidden-xs > .vehicleTitle > a') .set('url', '@href') .data(function(listing) { newUrl = listing.url; }); }
I need to be able to return the results of that data. I am getting stuck in callback hell. Please help
Just make newUrl
a global variable. Now it exists only inside your function, when function is over, so is your variable.