How to use the node-fetch.then function in node-fetch

To help you get started, we’ve selected a few node-fetch 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 hammerspacecouk / tubealert.co.uk / src / models / Status.js View on Github external
fetchNewLatest() {
    const now = this.dateTimeHelper.getNow();
    const url =
      "https://api.tfl.gov.uk/Line/Mode/tube,dlr,tflrail,overground/Status" +
      `?app_id=${this.config.TFL_APP_ID}` +
      `&app_key=${this.config.TFL_APP_KEY}`;

    this.logger.info("Fetching from TFL");
    // only include this require on invocation (so the memory is cleared)
    return require("node-fetch")(url) // eslint-disable-line global-require
      .then(response => response.json())
      .then(this.mutateData.bind(this))
      .then(data => this.storeStatus(now, data));
  }
github 1995parham / github-do-not-ban-us / together / TheDevMinerTV / index.js View on Github external
(async () => {
  require('node-fetch')('https://api.github.com/repos/1995parham/github-do-not-ban-us')
  .then(data => data.json())
  .then(data => console.log(`
GitHub is for everyone!
❤️️ to everyone of you ${data.forks} people!

The newest 100 forks:`))
  .then(() => require('node-fetch')('https://api.github.com/repos/1995parham/github-do-not-ban-us/forks?per_page=100'))
  .then(data => data.json())
  .then(data => data.forEach(repo => console.log(`- ${repo.owner.login}`)))
})()