How to use make-fetch-happen - 4 common examples

To help you get started, we’ve selected a few make-fetch-happen 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 goto-bus-stop / wikibattle / src / wiki.js View on Github external
const qs = require('querystring')
const makeFetch = require('make-fetch-happen')
const cheerio = require('cheerio')
const pkg = require('../package.json')

const HINT_LENGTH = 200 // characters
const BACKLINKS_LIMIT = 25 // amount of backlinks to retrieve
const CACHE_LOCATION = '/tmp/WikiBattle/'

const fetch = makeFetch.defaults({
  cacheManager: CACHE_LOCATION,
  headers: {
    'user-agent': `${pkg.name}/${pkg.version} (http://wikibattle.me/, renee@kooi.me)`
  }
})

/**
 * Represents a wikipedia article page.
 */

const WikiPage = class WikiPage {
  constructor (title, content, links) {
    this.title = title
    this.content = content
    this.links = links
  }
github tomchentw / react-google-maps / src / tx / ClassDefinition.js View on Github external
import { parse } from "url"
import toMarkdown from "to-markdown"
import makeFetchHappen from "make-fetch-happen"
import cheerio from "cheerio"
const fetch = makeFetchHappen.defaults({
  cacheManager: ".cache/", // path where cache will be written (and read)
})

const KlassName = process.argv[2]

fetch(
  "https://developers.google.com/maps/documentation/javascript/3.exp/reference"
)
  .then(it => it.text())
  .then(it => cheerio.load(it))
  .then($ => {
    const $content = $(`#${KlassName}`).parent()
    return contentToJS(KlassName, $, $content)
  })
  .then(it => process.stdout.write(JSON.stringify(it)))
  .catch(error => {
github lbryio / lbry.tech / app / views / api.js View on Github external
"use strict";



//  P A C K A G E S

import asyncHtml from "choo-async/html";
import dedent from "dedent";
import fs from "graceful-fs";
import raw from "choo/html/raw";

const fetch = require("make-fetch-happen").defaults({ cacheManager: "./cache" });

//  V A R I A B L E

// state.route === "api" || state.route === "api/*" ?  : ""
const apiScripts = "";



//  E X P O R T

module.exports = exports = state => parseApiFile(state.params.wildcard).then(response => asyncHtml`
  <div class="__slate">
    <aside class="api__toc">
      <div class="api__toc__search">
        <input type="search" placeholder="Search" id="input-search" class="api__toc__search__field">
        <div title="Clear search query" id="clear-search" class="api__toc__search__clear">×</div></div></aside></div>
github graalvm / graaljs / deps / npm / node_modules / npm-profile / index.js View on Github external
'use strict'
const fetch = require('make-fetch-happen').defaults({retry: false})
const validate = require('aproba')
const url = require('url')

exports.adduser = adduser
exports.login = login
exports.get = get
exports.set = set
exports.listTokens = listTokens
exports.removeToken = removeToken
exports.createToken = createToken

function adduser (username, email, password, conf) {
  validate('SSSO', arguments)
  if (!conf.opts) conf.opts = {}
  const userobj = {
    _id: 'org.couchdb.user:' + username,

make-fetch-happen

Opinionated, caching, retrying fetch client

ISC
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis

Popular make-fetch-happen functions