Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Designing Web APIs with Strapi

You're reading from   Designing Web APIs with Strapi Get started with the Strapi headless CMS by building a complete learning management system API

Arrow left icon
Product type Paperback
Published in Feb 2022
Publisher Packt
ISBN-13 9781800560635
Length 310 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Khalid Elshafie Khalid Elshafie
Author Profile Icon Khalid Elshafie
Khalid Elshafie
Mozafar Haider Mozafar Haider
Author Profile Icon Mozafar Haider
Mozafar Haider
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Section 1: Understanding Strapi
2. Chapter 1: An Introduction to Strapi FREE CHAPTER 3. Chapter 2: Building Our First API 4. Chapter 3: Strapi Content-Types 5. Chapter 4: An Overview of the Strapi Admin Panel 6. Section 2: Diving Deeper into Strapi
7. Chapter 5: Customizing Our API 8. Chapter 6: Dealing with Content 9. Chapter 7: Authentication and Authorization in Strapi 10. Chapter 8: Using and Building Plugins 11. Section 3: Running Strapi in Production
12. Chapter 9: Production-Ready Applications 13. Chapter 10: Deploying Strapi 14. Chapter 11: Testing the Strapi API 15. Other Books You May Enjoy Appendix: Connecting a React App to Strapi

Running the app

To run the sample app, first we will need to create a configuration file to set the API URL, then we can run the app using the start script:

  1. Create a .env.local file in the project root.
  2. Add the following to the new file: REACT_APP_STRAPI_API_URL=http://localhost:1337.
Figure 3: Example of the .env.local file

Figure 3: Example of the .env.local file

The REACT_APP_STRAPI_API_URL env variable points to the Strapi API we created in the book. This environment variable is referenced and used in services/api.ts. If you are running your Strapi instance on a different machine, make sure to adjust the value of this variable to point to your Strapi application.

  1. Save the changes to the file, and then from the terminal run the command yarn start to launch the development server. Once the server is up and running, a new browser tab should atomically open. If not, open your browser and navigate to http://localhost:3000. You will be presented with the login screen:
  2. ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime