Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.2 KB

README.md

File metadata and controls

51 lines (34 loc) · 1.2 KB

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.