Skip to main content

Vite

Vite is a fast modern build tool that supports native ES modules and TypeScript out of the box. Using lunex-http with Vite is straightforward.


Installation

Use your preferred package manager to install:

Using npm

npm install lunex-http

Using Yarn

yarn add lunex-http

Using pnpm

pnpm add lunex-http

Import and Usage Example

Create a JavaScript or TypeScript file and import LunexClient:

import LunexClient from 'lunex-http';

const client = new LunexClient('https://api.example.com', {
Authorization: 'Bearer YOUR_TOKEN'
});

async function fetchData() {
try {
const data = await client.getAsync('endpoint');
console.log(data);
} catch (error) {
console.error('Request failed:', error);
}
}

fetchData();

Notes

  • Vite automatically handles ESM imports and TypeScript, so no additional config is required.
  • lunex-http works seamlessly with Vite’s dev server and build process.
  • For React or Vue projects using Vite, follow framework-specific usage in their respective pages.