@all-in-js/fetch-functions-api

简化前端通过 fetch 请求 koa-functions-api

Usage no npm install needed!

<script type="module">
  import allInJsFetchFunctionsApi from 'https://cdn.skypack.dev/@all-in-js/fetch-functions-api';
</script>

README

fetch-functions-api

简化前端通过 fetch 请求 koa-functions-api

后端需要通过 koa-functions-api 实现 /api/functions 接口

import Fetch from '@all-in-js/fetch-functions-api';

const $fetch = new Fetch('/api/functions');

// GET
$fetch('api/helloWorld', {});

// POST, 暂时只支持 json
$fetch.post('api/helloWorld', {});

// combine
$fetch.combine({
  'api/helloWorld': {},
  'api/whatelse': {}
});