No description
|
|
||
|---|---|---|
| .woodpecker | ||
| .yarn/releases | ||
| packages | ||
| tools/scripts | ||
| .editorconfig | ||
| .eslintignore | ||
| .eslintrc.json | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .prettierignore | ||
| .prettierrc | ||
| .yarnrc.yml | ||
| CHANGELOG.md | ||
| jest.config.ts | ||
| jest.preset.js | ||
| nx.json | ||
| package.json | ||
| project.json | ||
| README.md | ||
| renovate.json | ||
| tsconfig.base.json | ||
| yarn.lock | ||
@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/dito 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) => {});
}