he-fetch

1.0.5 • Public • Published

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));

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i he-fetch

    Weekly Downloads

    0

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    2.18 kB

    Total Files

    3

    Last publish

    Collaborators

    • hehuang724