Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ducdev/fetch-no-cors
Bypass CORS for browser's Fetch API
https://github.com/ducdev/fetch-no-cors
Last synced: 23 days ago
JSON representation
Bypass CORS for browser's Fetch API
- Host: GitHub
- URL: https://github.com/ducdev/fetch-no-cors
- Owner: ducdev
- Created: 2021-03-28T07:08:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-03-29T16:11:12.000Z (over 3 years ago)
- Last Synced: 2024-04-26T14:22:21.470Z (6 months ago)
- Language: JavaScript
- Size: 41 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fetch No CORS
Bypass CORS for browser's Fetch API using https://github.com/Rob--W/cors-anywhere
1. Installation
npm:
```
npm i fetch-no-cors
```yarn:
```
yarn add fetch-no-cors
```2. Use
It's exactly like how we use the original `fetch`, you can either use it with await/async:
```
import fetchNoCors from "fetch-no-cors"// You need to setup your own cors-anywhere proxy instance using https://github.com/Rob--W/cors-anywhere
const CORS_ANYWHERE = "https://my-own-cors-anywhere-proxy.com"
const foo = async (url, options, CORS_ANYWHERE) => {
const res = await fetchNoCors(url, options)
console.log(res)
}
```or:
```
fetchNoCors(url, options, CORS_ANYWHERE)
.then(res => console.log(res))
.catch(err => console.error(err))
```