Quickstart

A quick dive into getting started with Lore

Step 2: Create a Tweet Model

In this step we're going to create a model for our tweet, and in the process, we'll learn about some of the functionality automatically provided by Lore as a result.

You can view the finished code for this step by checking out the fetching.2 branch of the completed project.

Create a Tweet Model

Before you can fetch data in Lore, you first need to create a model that represents the resource you want to fetch. Since we want to fetch tweets, we're going to create a tweet model.

Run this command to generate that model:

lore generate model tweet

This will create a model called tweet, and place the file at src/models/tweet.js.

You can learn more about the generate model command here.

Similar to the files in the /config folder, this file contains a lot of comments, which document the properties you can change, along with their default values. But if you ignore all the comments, this file is essentially empty:

// src/models/tweet.js
export default {

};

While it may not look like it, we now have all the code required to fetch tweets from the API, and we'll explore some of that functionality in the next step.

Visual Check-in

If everything went well, your application should now look like this. Still the same as before :)

Code Changes

Below is a list of files modified during this step.

src/models/tweet.js

export default {

};
export default {

}
export default {

}

Next Steps

Next we're going to talk about a design paradigm called convention over configuration, and introduce some of the functionality we just unlocked.