Skip to main content

Vue 3

Install lunex-http via your preferred package manager:

Using npm

npm install lunex-http

Using Yarn

yarn add lunex-http

Using pnpm

pnpm add lunex-http

Import and Usage with Composition API

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import LunexClient from 'lunex-http';

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

const users = ref(null);
const error = ref(null);

onMounted(async () => {
try {
users.value = await client.getAsync('users');
} catch (err: any) {
error.value = err.message;
}
});
</script>

<template>
<div v-if="error">Error: {{ error }}</div>
<div v-else-if="!users">Loading...</div>
<ul v-else>
<li v-for="user in users" :key="user.id">{{ user.name }}</li>
</ul>
</template>

Notes

  • Compatible with Vue 3 Composition API and TypeScript.
  • Works with Vue CLI, Vite, or other Vue bundlers.
  • No additional typings needed as lunex-http includes full TypeScript support.