Challenge: Create a Minimal Blog Engine Using Vuex
Assess your learning by creating a minimal blog engine using Vuex.
We'll cover the following
Task
Modify the provided code to use Vuex, and follow the steps below:
Open the
src/store.js
file.Define state properties for
posts
(an array to hold posts) andpost
(to hold the current post).Implement a getter named
postsCounter
to get the count of posts.Create mutations,
setPosts
andsetPost
, to update the state with posts and a single post, respectively.Create actions,
fetchPosts
andfetchPost
, to fetch posts and a single post, respectively, and commit the mutations.In
main.js
, import the store, and integrate it into the main Vue instance.Update components to interact with the store using
mapGetters
andmapActions
.Replace previous data handling logic related to posts with Vuex store actions and getters.
Expected output
The output of the task should look like the following:
Get hands-on with 1400+ tech skills courses.