Skip to content

Commit 7ccc616

Browse files
committed
Fix for travis error
1 parent b7d82c6 commit 7ccc616

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

nuxt.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const webpack = require('webpack')
22
const pkg = require('./package')
3-
const _ = require('lodash')
43

54
const 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

pages/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import Map from '~/components/Map'
99
1010
export 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: {

plugins/axios.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

0 commit comments

Comments
 (0)