File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 11const webpack = require ( 'webpack' )
22const pkg = require ( './package' )
3- const _ = require ( 'lodash' )
43
54const routerBase = process . env . DEPLOY_ENV === 'GH_PAGES' ? {
65 base : `/${ process . env . REPO_NAME } /`
@@ -16,7 +15,7 @@ module.exports = {
1615 */
1716 env : {
1817 accessToken : process . env . MAPBOX_TOKEN ,
19- apiUrl : process . env . API_URL || 'http://localhost:3000/'
18+ apiUrl : process . env . API_URL
2019 } ,
2120
2221 /*
@@ -53,7 +52,9 @@ module.exports = {
5352 /*
5453 ** Plugins to load before mounting the App
5554 */
56- plugins : [ ] ,
55+ plugins : [
56+ '~/plugins/axios'
57+ ] ,
5758
5859 /*
5960 ** Nuxt.js modules
Original file line number Diff line number Diff line change 88import Map from ' ~/components/Map'
99
1010export default {
11- async fetch ({ app: { $axios }, store, params }) {
12- const { data } = await $axios .get (` ${ process . env . apiUrl } /all` )
11+ async fetch ({ app: { $api }, store, params }) {
12+ const { data } = await $api .get (' /all' )
1313 store .commit (' SET_DATA' , data)
1414 },
1515 components: {
Original file line number Diff line number Diff line change 1+ export default function ( { $axios, redirect } , inject ) {
2+ // Create a custom axios instance
3+ const api = $axios . create ( {
4+ headers : {
5+ common : {
6+ Accept : 'text/plain, */*'
7+ }
8+ }
9+ } )
10+
11+ // Set baseURL to something different
12+ api . setBaseURL ( process . env . apiUrl )
13+
14+ // Inject to context as $api
15+ inject ( 'api' , api )
16+ }
You can’t perform that action at this time.
0 commit comments