Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-absolute

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-absolute

Fetch with absolute URLs.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Fetch Absolute

Fetch with default absolute URLs.

Build Status npm version

Tired of writing http://localhost in front of every fetch request? With fetch absolute you'll only write it once per host in your whole environment.

It works with both window.fetch and node-fetch.

Install

npm install fetch-absolute

Usage

var fetch = require('node-fetch');
var fetchAbsolute = require('fetch-absolute');

global.fetchApi = fetchAbsolute(fetch)('http://localhost:3030');

Example

Using node-fetch and fetch-absolute with Node 7 async/await:

const fetch = require('node-fetch');
const fetchAbsolute = require('fetch-absolute');

const fetchApi = fetchAbsolute(fetch)('http://localhost:3030');

it('should should display "It works!"', async () => {
  const response = await fetchApi('/');
  const json = await response.json();
  expect(json).to.eql({ msg: 'It works!' });
});

Requested absolute URLs must start with /, otherwise they will be treated as relative.

  • superagent-absolute - Superagent with default absolute URLs.

License

MIT © Gerard Rovira Sánchez

Keywords

FAQs

Package last updated on 26 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc