Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Created March 17, 2018 19:32
Show Gist options
  • Save Kelin2025/7f07bd0f7bdc138dde512fe5275f5d9c to your computer and use it in GitHub Desktop.
Save Kelin2025/7f07bd0f7bdc138dde512fe5275f5d9c to your computer and use it in GitHub Desktop.
Apicase rest tree
import fetch from '@apicase/adapter-fetch'
import { ApiService } from '@apicase/core'
import { ApiTree, restWrapped } from '@apicase/services'
const Root = new ApiService(fetch, { url: '/api' })
const api = new ApiTree(Root, [
/* Equal with previous example */
restWrapped('posts'),
/* Pick only specified routes */
restWrapped('posts', ['getAll']),
/* With custom URL's and additional payload */
restWrapped('posts', { getAll: { url: 'get_all' } }),
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment