1.1.1 • Published 1 month ago

cyberia-api v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Cyberia API

npm version npm downloads License Nuxt

My new Nuxt module for doing amazing things.

Quick Setup

  1. Add cyberia-api dependency to your project
# Using pnpm
pnpm add cyberia-api

# Using yarn
yarn add cyberia-api

# Using npm
npm install cyberia-api
  1. Add cyberia-api to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'cyberia-api'
  ]
})

That's it! You can now use $cyberiaApi in your Nuxt app ✨

Preparation

Add module the config to nuxt.config.ts

export default defineNuxtConfig({
  ...
    cyberiaApi: {
        accessTokenName: 'access-token',
        baseUrl: 'https://example.com/'
    },
})

accessTokenName is the name of the cookie storing your authorization token.

baseUrl needs no introduction

Usage

interface Response {
  message: string;
  data: string[];
}

const { data: testData } = await useAsyncData(
  () => $cyberiaApi<Response>(`/test`)
);

console.log(testData.value.message);

In this case, the testData variable will contain the response from https://example.com/test.

If there is a cookie named access-token, the following line will be added to the request headers:

    Authorization: `Bearer <access-token>`
1.1.1

1 month ago

1.1.0

1 month ago

1.0.4

1 month ago

1.0.2

2 months ago

1.0.3

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago