0.3.0 • Published 8 years ago

lazy-fetch v0.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago