Browser client for matter in motion framework
npm i mm-client-browser
import MM from 'mm-client-browser';
import HTTP from 'mm-client-browser/http';
const mm = new MM({
host: 'localhost:3000',
tls: false,
log: (level, ...args) => console.log(level, ...args)
});
mm.addTransport(HTTP());
mm.init(() => {
console.log('ready');
// example from post resource
mm.call('post.get', { })
});
Creates the matter-in-motion client. Settings are:
- host — string, the host name for the api server.
- tls — boolean, default true. Should client use secure connection.
- serializer — mime string, default 'application/json'. Data type mime that is expected from the server.
- api — string, path, default '/api'. Api path.
- log — function. Function that will be used to log.
Adds a transport.
Sets default transport.
Sets the authentication controller.
Returns null
if no authentication controller defined. Othewise calls the this.auth.isAuthenticated
method and returns the result.
Inits all the transports. Initis the authentication controller if present. Calls callback.
Calls the api. Similar calls will be throttled.
Adds will call hook.
Adds did call hook.
License: MIT
© velocityzen