1.0.5 • Published 3 years ago

he-fetch v1.0.5

Weekly downloads
12
License
MIT
Repository
-
Last release
3 years ago

he-fetch polyfill

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

Installation

npm install he-fetch

const fetch = require('he-fetch');

Importing

Importing will automatically polyfill window.fetch and related APIs:

import 'he-fetch';

GET JSON

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

Post JSON

var users = {
  name: 'name',
  age: 'age'
};

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

PUT JSON

var users = {
  name: 'name',
  age: 'age'
};

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

DELETE JSON

var users = {
  name: 'name',
  age: 'age'
};

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

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago