Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Created March 17, 2018 19:04
Show Gist options
  • Save Kelin2025/a6015bfba802e031efaf2f643a275224 to your computer and use it in GitHub Desktop.
Save Kelin2025/a6015bfba802e031efaf2f643a275224 to your computer and use it in GitHub Desktop.
Apicase services extending
import { ApiService } from '@apicase/core'
import fetch from '@apicase/adapter-fetch'
/* Api root with global logger and API base */
const ApiRoot = new ApiService(fetch, { url: '/api' })
.on('error', logError)
/* Inherit options and event listeners from ApiRoot */
const CreatePost = ApiRoot.extend({
url: 'posts',
method: 'POST',
headers: { token: localStorage.getItem('token') }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment