Get external data and use results in script elsewhere

This example makes a http request and uses the resulting data to fill in a form in the script. It could be extended to pull externally stored credentials and pass them in to prevent needing to save plain text credentials into Synthetics directly.

//This script makes a REST call then uses the results later in the script to fill in form data
var request = require('urllib-sync').request;
//Make a REST call to get some geolocation data
var result = request('');

  var parsedResponse = JSON.parse('utf-8'));
  return parsedResponse;
  console.log("Search for "+parsedResponse.geobytescity);