apiz-browser-client
v7.0.2
Published
Browser client for apiz
Downloads
13
Readme
apiz-browser-client
apiz-browser-client implements the APIzClient
interface for browser, based on tinyjx, so you can use options of tinyjx.
Usage
import { APIz } from 'apiz-ng';
import apizClient from 'apiz-browser-client';
const apiMeta = {
getBook: {
url: 'http://www.a.com'
}
};
const apis = new APIz(apiMeta, {
client: apizClient({
beforeSend(xhr) {
return false;
},
afterResponse(resData, status, xhr, url, reqData) {
console.log(resData);
},
complete(resData, xhr, url, reqData) {
console.log(resData);
},
retry: 3
})
});
apis.getBook().then(({data, next}) => {
console.log(data);
next();
})
beforeRequest
and afterResponse
are hooks of tinyjx.