apiz-browser-client

Browser client for apiz

Usage no npm install needed!

<script type="module">
  import apizBrowserClient from 'https://cdn.skypack.dev/apiz-browser-client';
</script>

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.