node-osmosis icon indicating copy to clipboard operation
node-osmosis copied to clipboard

Return data?

Open hartwm opened this issue 7 years ago • 1 comments

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

hartwm avatar Mar 03 '17 22:03 hartwm

Just make newUrl a global variable. Now it exists only inside your function, when function is over, so is your variable.

DmitryAlCh avatar Mar 22 '17 18:03 DmitryAlCh