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

@poyoman/auto-fetch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poyoman/auto-fetch

Auto API based on fetch and JS Proxys

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

auto-fetch

auto-fetch provides a Proxy generating fetch requests based on method names.

Quick start

npm i @poyoman/auto-fetch
const createAutoFetch = require('@poyoman/auto-fetch');

// ...

const api = createAutoFetch({
  baseUrl: 'https://example.org',
  headers: { /* some default headers */ },
});

api.users.get(); // GET https://example.org/users
api.user.jamy.setPreferences.post(); // POST https://example.org/user/jamy/setPreferences
api.user.jamy.setPreferences(); // POST is default request method => POST https://example.org/user/jamy/setPreferences

Doc


createAutoFetch(options)

Create a new api

  • options.baseUrl (required) string: Base url of future requests
  • options.headers (default: null) object: default headers of future requests

api.some.path.method()

You can put as much url segments before calling the function.

method can be any REST method (get, post, put, patch, delete)

Keywords

FAQs

Package last updated on 01 Feb 2023

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