Skip to content

Instantly share code, notes, and snippets.

@lukasborawski
Last active January 25, 2018 14:40
Show Gist options
  • Save lukasborawski/dd1ef3412d83acd29fba5c4728e7fd81 to your computer and use it in GitHub Desktop.
Save lukasborawski/dd1ef3412d83acd29fba5c4728e7fd81 to your computer and use it in GitHub Desktop.
Axios API Call Shorthand
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