1.0.1 • Published 10 months ago

vite-plugin-fetch v1.0.1

Weekly downloads
-
License
GPL-3.0-or-later
Repository
gitlab
Last release
10 months ago

vite-plugin-fetch

Description

The vite-plugin-fetch plugin addresses CORS (Cross-Origin Resource Sharing) issues encountered when using the Fetch API in JavaScript. By integrating this plugin, developers can make HTTP requests to external resources without being blocked by CORS restrictions.

Features

  • Interoperability: Utilizes native NodeJS fetch to handle requests, ensuring your request success without being blocked by CORS restrictions.
  • Ease of Use: Simply replace your JavaScript fetch calls with _fetch(), without requiring complex modifications to your existing code.
  • Real-time Results: Returns the results of requests directly to your JavaScript code, making it easier to process responses.

Installation

To install the plugin, use the following command:

npm install vite-plugin-fetch --save-dev

In your Vite configuration file (usually vite.config.js), add the plugin like this:

import { defineConfig } from 'vite'
import VitePluginFetch from 'vite-plugin-fetch'

export default defineConfig({
  plugins: [
    VitePluginFetch()
  ]
})

Usage

Here’s an example of how to use the plugin:

_fetch('https://httpbin.org/get')
  .then((response) => response.json())
  .then(console.log)
  .catch(console.error)

Contribution

Contributions are welcome! Feel free to submit issues or feature requests.

License

This project is licensed under the GPL-3.0-or-later license.

1.0.1

10 months ago

1.0.0

12 months ago