How to use the d3-request.text function in d3-request

To help you get started, we’ve selected a few d3-request 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 uber / react-vis / docs / docs-app / actions / index.js View on Github external
return (dispatch, getState) => {
    const filename = content.markdown;
    if (!filename) {
      return;
    }
    const contents = getState();
    if (contents.markdownPages.get(filename)) {
      // already loaded
      return;
    }
    dispatch(loadContentStart(filename));
    text(filename, (error, response) => {
      dispatch(loadContentSuccess(filename, error ? error.target.response : response));
    });
  };
}
github uber / luma.gl / website / src / actions / app-actions.js View on Github external
return (dispatch, getState) => {
    const {contents} = getState();
    if (filename in contents) {
      // already loaded
      return;
    }

    dispatch(loadContentStart(filename));
    text(filename, (error, response) => {
      dispatch(loadContentSuccess(filename, error ? error.target.response : response));
    });

  };
};
github zakandrewking / escher / src / utils.js View on Github external
function load_the_file (t, file, callback, value) {
  if (value) {
    if (file) console.warn('File ' + file + ' overridden by value.')
    callback.call(t, null, value)
    return
  }
  if (!file) {
    callback.call(t, 'No filename', null)
    return
  }
  if (_ends_with(file, 'json')) {
    d3_json(file, function(e, d) { callback.call(t, e, d) })
  } else if (_ends_with(file, 'css')) {
    d3_text(file, function(e, d) { callback.call(t, e, d) })
  } else {
    callback.call(t, 'Unrecognized file type', null)
  }
  return
}
github zakandrewking / escher / src / utils.js View on Github external
function load_css(css_path, callback) {
  var css = ""
  if (css_path) {
    d3_text(css_path, function(error, text) {
      if (error) {
        console.warn(error)
      }
      css = text
      callback(css)
    })
  }
  return false
}
github tmrowco / electricitymap-contrib / web / src / helpers / api.js View on Github external
return new Promise((resolve, reject) => {
    request.text(url).get(null, (err, res) => {
      if (err) {
        reject(err);
      } else if (!res) {
        reject(new Error(`Empty response received for ${url}`));
      } else {
        resolve(res);
      }
    });
  });
}

d3-request

A convenient alternative to XMLHttpRequest.

BSD-3-Clause
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis