1.1.0 • Published 3 years ago

wind-waker-client v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

CI npm semantic-release Commitizen friendly

wind-waker-client

Client side implementation for Wind Waker Nodejs Framework.

this package is isomorphic, you can use on Server/Client side. e.g

  • Use it to communicate 2 wind-waker servers.
  • Use it to consume your wind-waker server from vue, react, ... or any javascript client app.

Getting Started

import {Client} from 'wind-waker-client';

const client = new Client({ baseURL: 'http://localhost:4000' });

// request first parameter is the action name
const response = await client.request('hello');

// requesting with data, the default method is POST
const response = await client.request('hello', {name: 'Zelda'});

// change method to GET, notice the data don't change at all
const response = await client.request('hello', {name: 'Zelda'}, {method: 'GET'});

Documentation

wind-waker-client is an abstraction layer on top of Axios

Client

The Client class constructor get AxiosRequestConfig as argument to create a new axios instance for use the request method.

Definition:

class Client {
  axios: AxiosInstance;

  constructor(public config: AxiosRequestConfig) {
    this.axios = axiosHttp.create(config);
  }
}

All axios configurations are supported.

request Method

Definition:

request(action: string, data?: T, config: AxiosRequestConfig = {}): Promise; 

Definition with generics:

request<T, R = any>(action: string, data: T, config: AxiosRequestConfig = {}): Promise<AxiosResponse<R>>; 

Visit Axios Website, to more information about options and configurations

1.1.0

3 years ago

1.0.0

3 years ago