How to use the cheerio.getJSON function in cheerio

To help you get started, we’ve selected a few cheerio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sefaria / Sefaria-Project / static / js / sefaria / sefaria-06.js View on Github external
sheetsByTag: function(tag, callback) {
      // Returns a list of public sheets matching a given tag.
      var sheets = this._sheetsByTag[tag];
      if (sheets) {
        if (callback) { callback(sheets); }
      } else {
        var url = "/api/sheets/tag/" + tag;
         $.getJSON(url, function(data) {
            this._sheetsByTag[tag] = data.sheets;
            if (callback) { callback(data.sheets); }
          }.bind(this));
        }
      return sheets;
    },
    _userSheets: {},
github Sefaria / Sefaria-Project / static / js / sefaria / sefaria-06.js View on Github external
_api: function(url, callback) {
    // Manage API calls and callbacks to prevent duplicate calls
    if (url in this._apiCallbacks) {
      this._apiCallbacks[url].push(callback);
      return this._ajaxObjects[url];
    } else {
      this._apiCallbacks[url] = [callback];
      var ajaxobj = $.getJSON(url, function(data) {
        var callbacks = this._apiCallbacks[url];
        for (var i = 0; i < callbacks.length; i++) {
          callbacks[i](data);
        }
        delete this._apiCallbacks[url];
        delete this._ajaxObjects[url];
      }.bind(this));
      this._ajaxObjects[url] = ajaxobj;
      return ajaxobj;
    }
  }
});