Set value of cell/name in callback function

I’m trying to set the value of a cell named “restaurants” in a call back from Tabletop, but when I reference restaurants in another cell, I receive “RuntimeError: restaurants is not defined”.

Tabletop = require("")
  var publicSpreadsheetUrl = "";

    Tabletop.init( { key: publicSpreadsheetUrl,
                     callback: showInfo,
                     simpleSheet: true } )

  function showInfo(data, tabletop) {
    let restaurants = data;

Thank you for the help.l

Tabletop uses a callback-style API which you’ll need to adapt to use promises. Here’s how you’d do that:

data = new Promise((resolve, reject) => {
    key: url,
    callback: data => {
      if (data) resolve(data);
      else reject(new Error("unable to load"));
    simpleSheet: true

And here’s the live notebook:

I’ll also add an example of adapting a callback API to promises in the Introduction to Promises notebook. I forgot to mention that, so thanks for the reminder!

1 Like

Perfect! Thank you very much.