lazy-fetch
v0.3.0
Published
Define model for fetch api and call it later.
Downloads
3
Readme
lazy-fetch
Define model for fetch api and call it later.
Installation
$ npm install lazy-fetch
Examples
'use strict';
var LazyFetch = require('lazy-fetch');
module.exports = LazyFetch
.factory({
baseUrl: 'http://xxx.api.com/v1'
})
.headers({
'Accept': 'application/json',
'Content-Type': 'application/json'
})
.add('getTopicList', 'GET', '/topic')
.add('searchTopic', 'GET', '/topic/search');
Usage
_fetchTopicList: function() {
models.getTopicList({ limit: 98 })
.then((r) => { return r.json(); })
.then((res) => {
this.state.topicList = res.data.data;
});
}
License
MIT