Last active
May 31, 2017 03:26
-
-
Save wesleyguirra/8645a6de1059daa184a15a3e0690cae6 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Created by wesleyguirra on 5/26/17. | |
*/ | |
import axios from 'axios' | |
const client = axios.create({baseURL: 'http://localhost:4567/api/v1', headers: {'Authorization': localStorage.getItem('token')}}) | |
axios.interceptors.response.use((response) => { | |
return response | |
}, function (error) { | |
if (error.response.status === 401) { | |
console.log('unauthorized, logging out ...') | |
} | |
return Promise.reject(error) | |
}) | |
export default client |
This file contains 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
<script> | |
import CcButton from './Button' | |
import { getMedics } from '../services/medics' | |
export default { | |
data () { | |
return { | |
medics: '' | |
} | |
}, | |
components: { | |
CcButton | |
}, | |
methods: { | |
fetchUsers () { | |
console.log(getMedics()) | |
} | |
}, | |
mounted () { | |
setTimeout(() => { | |
this.fetchUsers() | |
}, 2000) | |
} | |
} | |
</script> |
This file contains 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
/** | |
* Created by wesleyguirra on 5/30/17. | |
*/ | |
import http from './http' | |
export function getMedics () { | |
return http.get('medic') | |
.then(function (response) { | |
console.log(response.data) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment