Boilerplate Nuxt mode SPA with request API from Client
# install dependencies
$ yarn install
# serve with hot reload at localhost:3000
$ yarn dev
# build for production
$ yarn build
# execute build
$ yarn start
# generate static project
$ yarn generate
Use request from API
After the Request, the action
'resource/method'
is executed, can be canceled by passing the parametershouldDispatch
. Example: await this.$api.[resource][method](payload, shouldDispatch)
const { data, status } = await this.$api.[resource][method](payload) // ex: this.$api.user.me({ id: 123 })
Use request from Store
await this.$store.$api[resource][method](payload) // ex: this.$store.$api.user.me({ id: 123 })
Create file .env
at project root or edit /src/envs.js
Example by https://jsonplaceholder.typicode.com/
API_BASE_URL: 'https://jsonplaceholder.typicode.com/'