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 Startedimport {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'});
#
Documentationwind-waker-client
is an abstraction layer on top of Axios
#
ClientThe 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 MethodDefinition:
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