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

Matt Moody Matt.Moody at marklogic.com
Wed Feb 8 13:09:10 PST 2017


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>
Mobile: +61 415 564 355
Skype:   matt.moody.ML
www.marklogic.com<http://www.marklogic.com/>
[.png]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20170208/d22d7398/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 8096 bytes
Desc: image001.png
Url : http://developer.marklogic.com/pipermail/general/attachments/20170208/d22d7398/attachment.png 


More information about the General mailing list