https://github.com/qddegtya/lazy-fetch
:pig2: Define model for fetch api and call it later
https://github.com/qddegtya/lazy-fetch
fetch nodejs nodejs-modules react-native
Last synced: 3 months ago
JSON representation
:pig2: Define model for fetch api and call it later
- Host: GitHub
- URL: https://github.com/qddegtya/lazy-fetch
- Owner: qddegtya
- License: mit
- Created: 2016-01-05T14:04:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T03:09:27.000Z (over 3 years ago)
- Last Synced: 2025-10-18T18:50:09.672Z (9 months ago)
- Topics: fetch, nodejs, nodejs-modules, react-native
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://nodei.co/npm/lazy-fetch/)
# lazy-fetch
Define model for fetch api and call it later.
## Installation
```
$ npm install lazy-fetch
```
## Examples
```js
'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
```js
_fetchTopicList: function() {
models.getTopicList({ limit: 98 })
.then((r) => { return r.json(); })
.then((res) => {
this.state.topicList = res.data.data;
});
}
```
# License
MIT