wind-waker-client
v1.1.0
Published
Client side implementation to Wind Waker nodejs framework.
Downloads
2
Readme
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 fromvue
,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