title: Caching results of Maps API call to reduce volume in Sheets
body: <p>I have a public form which incudes a place name, which I'm using the Places API to get the Place ID, to then do another call to look up an address. I need to optimize the volume of API calls so I'm trying to add caching so that Sheets doesn't re-call the two APIs unnecessarily.</p>
  <p>For some reason I can't get the caching to work, either it errors or I get &quot;object object&quot; as the response.</p>
  <pre><code>function locId(text) {
    var text = cache.get(cacheLocId);
    if (cacheLocId === null) {
      var API_KEY = 'XYZXYZXYZ';
      var baseUrl = 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json';
      var queryUrl = baseUrl + '?input=' + text + '&amp;inputtype=textquery&amp;key=' + API_KEY;
      if (text == null) {
        console. log(&quot;I QUIT!&quot;)
        return;
        }
      var response = UrlFetchApp.fetch(queryUrl);
      var json = response.getContentText();
      var placeId = JSON.parse(json);
    }
    cache.put(cacheLocId, placeId)
    console. log(text)
    console. log(placeId)
    return placeId.candidates[0].place_id;
  }
  </code></pre>