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

auth-fetch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth-fetch

Fetch JSON with a Bearer token

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

auth-fetch

Fetch JSON with a Bearer token

Install

npm install auth-fetch

Usage

When you create an instance, you can use every http method and it will automatically fill the API url and the Bearer token. Also, it will request the data as application/json, and it will unwrap the json result for you (equivalent to fetch(url).then(r => r.json()))

import AuthFetch from 'auth-fetch'

const fetch = new AuthFetch('/api/users', 'secret-token')

await fetch.get().then(users => console.log(users))
await fetch.put({id: 2, name: 'pablo'})
await fetch.put({id: 2, name: 'pablo varela'})
await fetch.delete({id: 2})

License

MIT

Author

me
Pablo Varela

Keywords

FAQs

Package last updated on 12 Feb 2021

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