Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Created March 17, 2018 19:02
Show Gist options
  • Save Kelin2025/fb4a74f5f663e9a39209cebdb6e6c976 to your computer and use it in GitHub Desktop.
Save Kelin2025/fb4a74f5f663e9a39209cebdb6e6c976 to your computer and use it in GitHub Desktop.
Apicase services
import { ApiService } from '@apicase/core'
import fetch from '@apicase/adapter-fetch'
/* Create a service */
const EditPost = new ApiService(fetch, {
url: '/api/posts/:id',
method: 'POST',
headers: { token: localStorage.getItem('token') }
})
/* Service has global event listeners */
EditPost.on('done', res => store.dispatch('updatePost', res))
/* The, we need to only pass the rest data */
EditPost.doRequest({
params: { id: 1 },
body: { title: 'Hello, Apicase' }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment