Skip to content

Instantly share code, notes, and snippets.

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