mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
1.1 KiB
1.1 KiB
W / Moxios
- This plugin will allow you to mock axios request reponses, so you don't have to wait for backend
Required internal plugins
- w/axios
Import in main.ts
import mocks from '@/plugins/w/moxios'
const app = createApp(App)
.use(axios)
.use(mocks, {
routes: {
'GET comments/project/(id)': true,
// Other routes
}
})
Usage
- Create
mockfolder inpublic - Create mocks in
mockfolder. For eaxmple when we want to mock routecomments/project/1we will createcommentsfolder inmockfolder, thenprojectfolder and then we will add(pid).GET.json. (Final path will be/public/mock/comments/project/(id).GET.json).
- NOTE:
(id)will match any project id - NOTE: You can change mocks path by adding
VUE_APP_PLATFORM=variable to .env. Path will change to/public/mock/${VUE_APP_PLATFORM}/...
- After calling
comments/project/1we will get response from/public/mock/comments/project/(id).GET.jsonfile
Enable / Disable from local storage
- we can enable/disable moxios by typing
localStorage.setItem('isMoxios', 'true')orlocalStorage.setItem('isMoxios', 'false')