@jojoxd/http-client
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@jojoxd/http-client

A Simple HTTP Client using ky and TsED json-mapper

Installation

yarn install @jojoxd/http-client

Usage

Standalone and Browser

import { HttpClient } from '@jojoxd/http-client';

const client = new HttpClient();

const response = await client.get('https://example.org/');

TsED

NOTE: This requires @tsed/di to be installed.

// Server.ts

import '@jojoxd/http-client/tsed';

@Configuration(...)
export class Server {}

// Service.ts
import { Service, Inject } from '@tsed/common';
import { HttpClient } from '@jojoxd/http-client';

@Service()
class Service
{
    @Inject()
    protected readonly client!: HttpClient;

    async doSomething(): Promise<void>
    {
        await this.client.get('https://example.org');
    }
}

Vue

// main.ts

import { createApp } from 'vue';
import { createHttpClient } from '@jojoxd/http-client/vue';

const app = createApp(RootComponent);

app.use(createHttpClient(/* Options */));

// Component, Composition function etc.
import { HttpClient } from '@jojoxd/http-client/vue';
import { inject } from 'vue';

function composedFunction()
{
    const client = inject(HttpClient);

    client.get('https://example.org/').then((data) => {});
}

Readme

Keywords

none

Package Sidebar

Install

npm i @jojoxd/http-client

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

17.2 kB

Total Files

12

Last publish

Collaborators

  • bakaxd