1.0.7 • Published 4 years ago

leefetch v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

#leefetch polyfill

fetch() 函数用于封装请求接口,其中包含 fetch.get() / fetch.post() / fetch.push() / fetch.delete()。

Installation

npm install leefetch --save

const fetch = require('leefetch');

Usage

For a more comprehensive API reference that this polyfill supports,refer to https://github.com/drrdrrdrr/leefetch

Importing

Importing will automatically polyfill window.fetch and related APIs:

import 'leefetch';

GET JSON

fetch.get('http://jsonplaceholder.typicode.com/users').then(users => {
    console.log(users);
});

Post JSON

var users={
    name:'Kulas Light',
    age:'25'
};

fetch.post('/users',users).then(res => console.log(res));

PUT JSON

var users={
    name:'Kulas Light',
    age:'25'
};

fetch.put('/users/:id',users).then(res => console.log(res));

DELETE JSON

var users={
    name:'Kulas Light',
    age:'25'
};

fetch.delete('/users/:id').then(res => console.log(res));
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago