Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

shawnbot/now-fetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

now-fetch

A bare-bones fetch wrapper for the Now API that:

  • Sets the base URL for requests to https://api.zeit.co, or the url option
  • Lazily finds your Now authentication token with now-token and automatically sets the Authorization header

Installation

npm install --save now-fetch

Usage

The default export of now-fetch is a function that configures the fetch() wrapper with options:

const makeNowFetch = require('now-fetch')
const nowFetch = makeNowFetch()
// or, more succinctly:
const nowFetch = require('now-fetch')()

nowFetch('/v2/now/deployments')
  .then(data => {
    console.warn('You have %d deployments.', data.deployments.length)
  })
  .catch(error => {
    console.error('Oops:', error)
    process.exitCode = 1
  })

Fetch wrapper options

Option Description Default
token Provides the Now access token (use now-token)
tokenOptions If no token is provided, pass these options to now-token
url Set the request base URL https://api.zeit.co

Fetch options

See the node-fetch docs for which options you can pass to the configured fetch() function.

About

A bare-bones fetch() wrapper for the Now API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published