@metahkg/api
TypeScript icon, indicating that this package has built-in type declarations

6.15.1 • Public • Published

Metahkg Api

Client for the metahkg server. Generated with the openapi spec using nswag.

Regenerate

yarn generate

Install

yarn add @metahkg/api

Usage

Function names are based on operationIds.
For example, if the operationId is commentCreate, you can use api.commentCreate.

For operationIds of requests see api docs.

import { Client } from "@metahkg/api";

const axios = Axios.create();

axios.interceptors.request.use((config) => {
    const token = localStorage.getItem("token");
    if (token && config.headers) config.headers.Authorization = `Bearer ${token}`;
    return config;
});

axios.interceptors.response.use((response) => {
    if (response.headers.token) localStorage.setItem("token", response.headers.token);
    return response;
});

const api = new Client("https://dev.metahkg.org/api", axios);

api
  .thread(1)
  .then(console.log)
  .catch(console.error);

Readme

Keywords

none

Package Sidebar

Install

npm i @metahkg/api

Weekly Downloads

27

Version

6.15.1

License

MIT

Unpacked Size

1.15 MB

Total Files

13

Last publish

Collaborators

  • wc-yat