How to use the wretch.default function in wretch

To help you get started, we’ve selected a few wretch 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 snipsco / create-snips-action / static / src / factories / httpFactory.js View on Github external
const { default: wretch } = require('wretch')
const { dedupe } = require('wretch-middlewares')

const BASE_URL = 'https://pokeapi.co/api/v2'

const http = wretch(BASE_URL)
    // Add a dedupe middleware, throttling cache would also be useful to prevent excessive token usage.
    // (https://github.com/elbywan/wretch-middlewares)
    .middlewares([
        dedupe()
    ])

module.exports = {
    init(httpOptions = {}) {
        wretch().polyfills({
            fetch: httpOptions.mock || require('node-fetch')
        })
    },
    get() { return http }
}
github snipsco / create-snips-action / static / src / factories / httpFactory.js View on Github external
init(httpOptions = {}) {
        wretch().polyfills({
            fetch: httpOptions.mock || require('node-fetch')
        })
    },
    get() { return http }

wretch

A tiny wrapper built around fetch with an intuitive syntax.

MIT
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis

Popular wretch functions