Skip to content

hebertsilva/nuxt-spa-starter

Repository files navigation

Nuxt SPA Boilerplate

Boilerplate Nuxt mode SPA with request API from Client

Setup

# 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

Usage

Use request from API

After the Request, the action 'resource/method' is executed, can be canceled by passing the parameter shouldDispatch. 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 })

Environment variable

Create file .env at project root or edit /src/envs.js

Example by https://jsonplaceholder.typicode.com/

  API_BASE_URL: 'https://jsonplaceholder.typicode.com/'

About

Boilerplate Nuxt mode SPA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published