In this project you will build a Tourio App, the best friend of all travelers: it displays sights you want to visit and lets you edit them.
- Set up a database; use the
lib/db.jsonfile to insert sample data. - In
pages/api/index.js, replace theplacesvariable imported fromlib/db.jswith aGETrequest from your database. - Do the same in
pages/api/[id]/index.jsfor the details page.
- In
pages/create.js, write theaddPlacefunction to start aPOSTrequest. - Write the
POSTAPI route inpages/api/places/index.js. - Submitting the form should redirect the user to the homepage
/.
- In
pages/places/[id]/edit.js, write theeditPlacefunction to start aPATCHrequest. - Write the
PATCHAPI route inpages/api/[id]/index.js
- In
pages/places/[id].index.js, write thedeletePlacefunction to start aDELETErequest. - Write the
DELETEAPI route inpages/api/places/[id]/index.js.
- Deploy your app to Vercel and make sure the deployment can access the cloud database with the help of environment variables.
To run project commands locally, you need to install the dependencies using npm i first.
You can then use the following commands:
npm run devto start the development servernpm run buildto create a production buildnpm run startto start the production buildnpm run testto run the tests in watch mode (if available)
💡 This project requires a bundler. You can use
npm run devto start the development server. You can then view the project in the browser athttp://localhost:3000. The Live Preview Extension for Visual Studio Code will not work for this project.