Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bergos/proto-fetch
Protocol handler wrapper for fetch
https://github.com/bergos/proto-fetch
Last synced: about 2 months ago
JSON representation
Protocol handler wrapper for fetch
- Host: GitHub
- URL: https://github.com/bergos/proto-fetch
- Owner: bergos
- License: mit
- Created: 2017-10-18T21:51:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T22:30:55.000Z (about 1 year ago)
- Last Synced: 2024-11-17T23:45:47.758Z (2 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# proto-fetch
[![build status](https://img.shields.io/github/actions/workflow/status/bergos/proto-fetch/test.yaml?branch=master)](https://github.com/bergos/proto-fetch/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/proto-fetch.svg)](https://www.npmjs.com/package/proto-fetch)A protocol handler wrapper for fetch.
## Usage
`proto-fetch` doesn't contain any fetch implementations.
A map of protocol to implementation must be given to the constructor.
This example shows how to create a fetch for file, http and https URLs:```javascript
import fileFetch from 'file-fetch'
import httpFetch from 'nodeify-fetch'
import protoFetch from 'proto-fetch'const fetch = protoFetch({
[null]: fileFetch,
file: fileFetch,
http: httpFetch,
https: httpFetch
})const res = await fetch(`file://${process.cwd()}/package.json`)
```