Created
March 17, 2018 19:02
-
-
Save Kelin2025/fb4a74f5f663e9a39209cebdb6e6c976 to your computer and use it in GitHub Desktop.
Apicase services
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 { 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