8 |
9 |
10 |
38 |
39 |
57 |
--------------------------------------------------------------------------------
/plugins/README.md:
--------------------------------------------------------------------------------
1 | # PLUGINS
2 |
3 | **This directory is not required, you can delete it if you don't want to use it.**
4 |
5 | This directory contains your Javascript plugins that you want to run before mounting the root Vue.js application.
6 |
7 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins).
8 |
--------------------------------------------------------------------------------
/plugins/axios.js:
--------------------------------------------------------------------------------
1 | export default function ({$axios}) {
2 | $axios.setHeader('AUTHORISATION', 'Bearer ln123ncoimokmsdfoi')
3 | $axios.onRequest(config => {
4 | console.log('Making request to ' + config.url)
5 | })
6 | }
7 |
--------------------------------------------------------------------------------
/static/README.md:
--------------------------------------------------------------------------------
1 | # STATIC
2 |
3 | **This directory is not required, you can delete it if you don't want to use it.**
4 |
5 | This directory contains your static files.
6 | Each file inside this directory is mapped to `/`.
7 |
8 | Example: `/static/robots.txt` is mapped as `/robots.txt`.
9 |
10 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static).
11 |
--------------------------------------------------------------------------------
/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vueschool/nuxt-async-data/69959f9c64c9f31f193e08b02c4b89f4b72f690f/static/favicon.ico
--------------------------------------------------------------------------------
/store/README.md:
--------------------------------------------------------------------------------
1 | # STORE
2 |
3 | **This directory is not required, you can delete it if you don't want to use it.**
4 |
5 | This directory contains your Vuex Store files.
6 | Vuex Store option is implemented in the Nuxt.js framework.
7 |
8 | Creating a file in this directory activate the option in the framework automatically.
9 |
10 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).
11 |
--------------------------------------------------------------------------------
/store/index.js:
--------------------------------------------------------------------------------
1 | export const state = () => ({
2 |
3 | })
4 | export const getters = {}
5 |
--------------------------------------------------------------------------------
/store/posts.js:
--------------------------------------------------------------------------------
1 | export const state = () => ({
2 | all: []
3 | })
4 |
5 | export const actions = {
6 | async fetchAllPosts ({commit}) {
7 | let posts = await this.$axios.$get('posts')
8 | commit('setPosts', posts)
9 | },
10 |
11 | async fetchPost ({commit}, id) {
12 | let post = await this.$axios.$get(`posts/${id}`)
13 | commit('setPost', post)
14 | }
15 | }
16 |
17 | export const mutations = {
18 | setPost (state, post) {
19 | state.all.push(post)
20 | },
21 | setPosts (state, posts) {
22 | state.all = posts
23 | }
24 | }
25 |
--------------------------------------------------------------------------------