Last active
January 25, 2018 14:40
-
-
Save lukasborawski/dd1ef3412d83acd29fba5c4728e7fd81 to your computer and use it in GitHub Desktop.
Axios API Call Shorthand
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
import axios from 'axios' | |
export default { | |
get (path) { | |
if (path.indexOf('/') !== 0) { | |
path = '/' + path | |
} | |
return axios | |
.get('//' + process.env.apiHost + ':' + process.env.apiPort + '/api' + path) | |
.then(({data}) => data) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment