Fetching data
Before diving into this chapter, make sure you've followed the steps in the technical requirements section. Once you've completed the setup guide, let's briefly revisit the key steps to prevent any issues:
- Run
npm i
to install all dependencies. - If you are missing a
.env
file in your project’s root, create a new.env
file and add the following line to it:DATABASE_URL="file:./dev.db"
Prisma – our database toolkit of choice – uses the
DATABASE_URL
environment variable to connect to our database. - Next, run
npm run build
to generate the Prisma client for our data schema. Prisma reads our Prisma schema from theprisma/schema.prisma
file and generates types and functions for us to work with. - Run
npm run update:db
to create or update the SQLite database. We use SQLite with Prisma to persist our development data. - Finally, run
npm run seed
to seed our local database with mock data. You can find the mock script...