Skip to main content

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 nameconst response = await client.request('hello');
// requesting with data, the default method is POSTconst response = await client.request('hello', {name: 'Zelda'});
// change method to GET, notice the data don't change at allconst 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