Created
March 17, 2018 19:09
-
-
Save Kelin2025/6cb9653e180324f447ccca93ca07765e to your computer and use it in GitHub Desktop.
Apicase meta
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
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