Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Created March 17, 2018 19:08
Show Gist options
  • Save Kelin2025/49cbe6ad0c8a3f3230f2a66d0631827f to your computer and use it in GitHub Desktop.
Save Kelin2025/49cbe6ad0c8a3f3230f2a66d0631827f to your computer and use it in GitHub Desktop.
Apicase hooks + extend
const ApiRoot = ApiRoot.extend({
url: '/api',
hooks: {
/* Inject our token and go to the next step */
before ({ payload, next }) {
const token = localStorage.getItem('token')
next(withToken(token, payload))
}
}
})
const GetProfile = ApiRoot.extend({ url: 'profile' })
const CreatePost = ApiRoot.extend({ url: 'profile', method: 'POST' })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment