Vuejs: where should I place some common js util in a vue-router SPA? Vuejs: where should I place some common js util in a vue-router SPA? vue.js vue.js

Vuejs: where should I place some common js util in a vue-router SPA?


Here is my choice

├── index.html└── src    ├── main.js    ├── config.js        # Here I define global constants like a base url for vue-resource    ├── api              # here is all the http calls using Vue.resource    │   ├── index.js    │   └── resource.js  # here I define interceptors, for errors log, auth, etc    ├── components    │   ├── utils        # Here I define common functions for components    │   ├── App.vue    │   └── ...    └── vuex        ├── store.js     # exports the store (with initial state and mutations)        └── actions.js   # exports all actions

So what you want, according to my file structure, should be in the src/components/utils folder, at least that it uses some http calls, in that case, it would be part of the src/api api folder. In this case, the routes are in the main.js file, some people prefer to have a dedicated file routes.js in the src folder, it's up to you