Skip to content

Instantly share code, notes, and snippets.

@sultaniman
Created May 13, 2018 11:48
Show Gist options
  • Select an option

  • Save sultaniman/b0f3cd613292ebdd16e08624a8a690d5 to your computer and use it in GitHub Desktop.

Select an option

Save sultaniman/b0f3cd613292ebdd16e08624a8a690d5 to your computer and use it in GitHub Desktop.
import { checkResponse, get, post } from '@/helpers/http'
export function getCSRFToken() {
return get('/api/security/csrf/token')
.then(checkResponse)
}
export function verifyToken(token) {
token = token || localStorage.token
if (token) {
return post('/api/auth/token/verify', {token})
.then(checkResponse)
}
return Promise.reject(new Error('ERR_NO_TOKEN'))
}
export function loginUser(credentials) {
return post('/api/auth/token', credentials)
.then(checkResponse)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment