From the course: Building Vue and Node Apps with Authentication

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a data store in your service

Creating a data store in your service

From the course: Building Vue and Node Apps with Authentication

Start my 1-month free trial

Creating a data store in your service

- [Instructor] In this video, we'll create a data store which our components can save data into, and our other components can read data from, creating a centralized object that handles our data for us. Before we get started, make sure your server is running since we had shut it down in the previous video. And then let's head over to our front end project. In here, let's create a new file under our source folder, called store.js. Then in here, let's create a new object called state. And then we'll create the messages property that's set to an empty array. And now let's add just two, simple placeholder messages. Save that. And then let's import our new store into our messages component. And since this is located above the components folder and in our source folder, we use ../store.js to access it. Now as a simple test, we'll try to get our messages and display them from the store, instead of from the back end. So I'll comment out line 33 as a test. And then on line 24, I'll initialize…

Contents