[MarkLogic Dev General] How to pass parameters between JavaScript functions?

Sam Mefford Sam.Mefford at marklogic.com
Wed Feb 8 13:14:13 PST 2017


I think you need to add "return" before

  parseFlights(resp);

in the getFlightsInAir function.

Sam Mefford
Senior Engineer
MarkLogic Corporation
sam.mefford at marklogic.com<mailto:sam.mefford at marklogic.com>
Cell: +1 801 706 9731
www.marklogic.com<http://www.marklogic.com>

This e-mail and any accompanying attachments are confidential. The information is intended
solely for the use of the individual to whom it is addressed. Any review, disclosure, copying,
distribution, or use of this e-mail communication by others is strictly prohibited. If you
are not the intended recipient, please notify us immediately by returning this message to
the sender and delete all copies. Thank you for your cooperation.

On 2/8/2017 2:09 PM, Matt Moody wrote:
> > ML JavaScript newbie question… > > > > I’m simply trying to pass the response from my httpGet call into my > parseFlights function. The httpGet call returns a valid JSON > document. However, it looks like the parameter that gets passed to > the parseFlights function is always blank. > > > > Why? > > > > > > declareUpdate(); > > > > var username = 'moody1'; > > var apiKey = '#########'; > > > > var fxml_base_url = > 'http://flightxml.flightaware.com/json/FlightXML2/'; > > var url_endpoint = 'SearchBirdseyeInFlight?howMany'; > > var url = fxml_base_url + url_endpoint; > > > > function getFlightsInAir() { > > var resp = fn.subsequence(xdmp.httpGet(url, > {"authentication":{"method":"basic","username":username,"password":apiKey}}), > 2, 1); > > > > // return resp;          // this displays a valid JSON document > > parseFlights(resp);      // pass the JSON document to parseFlights > function > > }; > > > > function parseFlights(flights) { > > return flights;          // this data is always blank > > }; > > > > getFlightsInAir(); > > > > > > > > Any help would be appreciated!! > > * * > > *Matt Moody* > > Sales Engineer > > MarkLogic Pty Ltd > > matt.moody at marklogic.com<mailto:matt.moody at marklogic.com> <mailto:matt.moody at marklogic.com><mailto:matt.moody at marklogic.com> > > Mobile: +61 415 564 355 > > Skype:   matt.moody.ML > > www.marklogic.com<http://www.marklogic.com> <http://www.marklogic.com/><http://www.marklogic.com/> > > .png > > > > _______________________________________________ General mailing list > General at developer.marklogic.com<mailto:General at developer.marklogic.com> Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20170208/4d6f4177/attachment-0001.html 


More information about the General mailing list