Created
March 17, 2018 19:29
-
-
Save Kelin2025/75dd9c7d6471451becfc8e95b270dbdd to your computer and use it in GitHub Desktop.
Services tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from '@apicase/adapter-fetch' | |
import { ApiTree } from '@apicase/services' | |
import { ApiService } from '@apicase/core' | |
const Root = new ApiService(fetch, { url: '/api' }) | |
const api = new ApiTree(Root, [ | |
{ url: 'posts', children: [ | |
{ name: 'postsGetAll', url: '', method: 'GET' }, | |
{ name: 'postsCreate', url: '', method: 'POST' }, | |
{ name: 'postsGetOne', url: ':id', method: 'GET' }, | |
{ name: 'postsUpdOne', url: ':id', method: 'PUT' }, | |
{ name: 'postsRmvOne', url: ':id', method: 'DELETE' } | |
] }, | |
{ url: 'profile', children: [/*...*/] } | |
]) | |
api('postsGetAll').doRequest() | |
api('postsCreate').doRequest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment