sairion / ajaxo

Promise-based Ajax Wrapper with Simple Configurations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ajaxo - A Simple Ajax Wrapper (WIP)

Ajaxo is a promise-based Ajax wrapper with simple configurations, built with modern JavaScript technology. More docs and examples is coming.

// api.js
import {APIBuilder} from 'ajaxo';

var definitions = {
    report: {
        url: '/report/<%= id %>',
        type: 'POST',
    }
};
export var API = APIBuilder(definitions);

// request-actions.js
API.report()
    .resolveWith({ id: 1 })
    .post()
    .then(response => {
        doSomethingWith(response);
    })
    .catch(xhr => {
        ...
    });

Import dist lib or ES2015 version

If you are willing to use pre-compiled ES2015 src directly, import from ajaxo/lib instead like:

import {APIBuilder} from 'ajaxo/lib/api';

About

Promise-based Ajax Wrapper with Simple Configurations


Languages

Language:JavaScript 100.0%