Skip to content

hebertsilva/nuxt-starter

Repository files navigation

Nuxt Boilerplate (Server render)

Boilerplate Nuxt mode server with request API from Client (Proxy)

Setup

# install dependencies
$ yarn install

# serve with hot reload at localhost:3000
$ yarn dev

# build for production and launch server
$ yarn build
$ yarn start

Usage Base Api

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 })

Request method in client for server default: POST

await this.$api.[resource][method](payload, 'GET', shouldDispatch) // this.$store.$api.user.me({ id: 123 }, 'GET') 

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

  SITE_URL=<url_site>
  BASE_API_URL=<url_api>
  PROXY_API_URL=<url_proxy>/api

For detailed explanation on how things work, check out Nuxt.js docs.

About

Boilerplate Nuxt with Express, Axios and Sass

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published