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
Modern JavaScript Web Development Cookbook

You're reading from   Modern JavaScript Web Development Cookbook Easy solutions to common and everyday JavaScript development problems

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher Packt
ISBN-13 9781788992749
Length 642 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Federico Kereki Federico Kereki
Author Profile Icon Federico Kereki
Federico Kereki
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Working with JavaScript Development Tools 2. Using Modern JavaScript Features FREE CHAPTER 3. Developing with Node 4. Implementing RESTful Services with Node 5. Testing and Debugging Your Server 6. Developing with React 7. Enhancing Your Application 8. Expanding Your Application 9. Debugging Your Application 10. Testing Your Application 11. Creating Mobile Apps with React Native 12. Testing and Debugging Your Mobile App 13. Creating a Desktop Application with Electron 14. Other Books You May Enjoy

Adding routes

No matter what kind of server you are building (a RESTful one, as we plan to do, or any other kind), you'll have to deal with routing, and Node and Express together provide easy ways of doing this.

Going back to our database from the Working with a database section in the previous chapter, in a RESTful fashion, we should provide the following routes, allowing for the given methods:

  • /countries (GET to obtain the list of all countries, and POST to create a new country)
  • /countries/someCountryId (GET to access a country, PUT to update one, and DELETE to delete one)
  • /regions (GET to get all regions of all countries, POST to create a new region)
  • /regions/someCountryId (GET to get all regions of a given country)
  • /regions/someCountryId/someRegionId (GET to access a region, PUT to update one, DELETE to delete one)
  • /cities (GET to get all cities – but we won...
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 $19.99/month. Cancel anytime