Per code below, a direct call to getWeather in the editor executes successfully to completion. But when triggered via onEdit in the spreadsheet, it properly displays my debug line "In getWeatherDaily1" but never completes after that. What am I doing wrong? I need to use onEdit to run my function.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Waypoints");
function onEdit(e) {
if (e.source.getSheetName()==sh.getName()) {
getWeather();
};
};
function getWeather() {
var lat = 34.639702;
var lng = -84.191499;
getWeatherDaily(lat,lng);
};
function getWeatherDaily(theLat,theLng) {
var gpsURL = "https://api.weather.gov/points/" + theLat + "," + theLng;
SpreadsheetApp.getUi().alert("In getWeatherDaily1 " + gpsURL + "."); // Debug
var gpsResponse = UrlFetchApp.fetch(gpsURL, {method: 'GET',headers: {'Content-Type': 'application/json','Accept': 'application/json'} });
SpreadsheetApp.getUi().alert("In getWeatherDaily2 " + gpsResponse); // Debug
};
Logger.log(varToLog)