You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial has been really useful for me so thanks for this! Anyway I had some problems when I have started developing because the only one command provided for dev is npm run dev that only starts Vue and not the API server. In this case I have edited package.json with a new command:
this command uses concurrently package to start both Vue and API server and nodemon to auto restart server on changes.
Another suggestion is for API calls. You use axios.get('http://localhost:3000/book/') but in a production enviroment this will not work when a user visit the page from remote so I have also added this line:
var port = 3000; //API PORT
axios.defaults.baseURL = location.protocol + '//' + location.hostname + ':' + port;
so API calls will look like axios.get('/book').
What do you think about this changes?
The text was updated successfully, but these errors were encountered:
robertsLando
changed the title
SUppport for development enviroment and improvements
Support for development enviroment and improvements
Feb 20, 2018
The axios defaults should be used in every file that uses axios, for this reason the best thing should be to create an apis.js file with functions for alla api requests and put the axios default there. I only make api calls in app.js so I have placed the axios default there
This tutorial has been really useful for me so thanks for this! Anyway I had some problems when I have started developing because the only one command provided for dev is
npm run dev
that only starts Vue and not the API server. In this case I have edited package.json with a new command:this command uses
concurrently
package to start both Vue and API server andnodemon
to auto restart server on changes.Another suggestion is for API calls. You use
axios.get('http://localhost:3000/book/')
but in a production enviroment this will not work when a user visit the page from remote so I have also added this line:so API calls will look like
axios.get('/book')
.What do you think about this changes?
The text was updated successfully, but these errors were encountered: