Nuxt.js API Example using Vuex and axios
This article provides an example of a Nuxt.js application that uses Vuex, axios, and a REST API. It demonstrates how to use the Nuxt fetch() method to fill the Vuex Store for a posts listing page and a dynamic post page for individual posts. The article also showcases how to use the head property to set the meta title property dynamically based on the returned post object. Other noteworthy aspects of the example include the use of Nuxt Modules to add Bulma, markdown-it, and Font Awesome, as well as the utilization of a menu.js file in the middleware directory to handle the closing of the mobile dropdown menu when a link is selected. The application is hosted on Netlify as a static site.
To install the Nuxt API Example, follow these steps:
git clone [repository-url]
cd project-directory
npm install
npm run dev
http://localhost:3000
This article presents a comprehensive example of a Nuxt.js application that showcases the use of Vuex, axios, and a REST API. It demonstrates how to fetch data using Nuxt’s fetch() method and populate the Vuex Store for both a posts listing page and a dynamic post page. Additionally, the example highlights the dynamic setting of the meta title property using the head property and the returned post object. The article also discusses the use of Nuxt Modules to add popular libraries like Bulma, markdown-it, and Font Awesome. The example code includes a menu.js file in the middleware directory, which handles the closure of the mobile dropdown menu when a link is selected. Lastly, the application is hosted on Netlify as a static site, providing a seamless and efficient hosting solution.