A web application that helps you discover random travel destinations by continent. Select a continent and get a random country with its key information including capital city, currency, and language.
WhereToTravel is a simple and fun destination generator that uses the REST Countries API to provide users with random country suggestions based on their continent preference. Perfect for travelers looking for inspiration for their next adventure!
- Continent Selection: Choose from 7 continents (Asia, Africa, North America, South America, Antarctica, Europe, Oceania) or get a random destination
- Random Country Generator: Get a random country from your selected continent
- Country Information: View key details about the selected country:
- Country name
- Capital city
- Official currency
- Primary language
- Clean UI: Simple and intuitive interface with a warm, travel-inspired design
- Node.js - Runtime environment
- Express.js - Web framework
- EJS - Template engine for server-side rendering
- Axios - HTTP client for API requests
- Body-parser - Middleware for parsing form data
- REST Countries API - Public API for country data
- Clone or download this repository
- Navigate to the project directory:
cd WhereToTravel - Install dependencies:
npm install
- Start the server:
node index.js
- Open your browser and navigate to:
http://localhost:3000 - Select a continent from the dropdown menu (or leave it as "Random one")
- Click "Go" to get a random country suggestion
- View the country information displayed on the page
WhereToTravel/
├── index.js # Main server file
├── package.json # Project dependencies and configuration
├── views/
│ └── index.ejs # Main HTML template
├── public/
│ └── styles/
│ └── main.css # Styling for the application
└── README.md # Project documentation
This application uses the REST Countries API:
- Base URL:
https://restcountries.com/v3.1/region/{region} - Endpoint:
/v3.1/region/{region} - Method: GET
- Response: JSON array of country objects
The API provides comprehensive country data including names, capitals, currencies, languages, and more.
- GET Request (
/): On initial page load, fetches a random country from Asia - POST Request (
/): When a user submits the form:- Captures the selected continent
- Fetches all countries from that region via the REST Countries API
- Randomly selects one country from the list
- Extracts and displays: country name, capital, currency, and language
- Renders the result on the page
- Error Handling: Gracefully handles API errors and displays error messages
- Responsive Design: Mobile-friendly layout that adapts to different screen sizes
- Server-side Rendering: Uses EJS templates for dynamic content rendering
Made with ❤️ by Chloe Yang
- The application defaults to showing a random country from Asia on initial load
- If a country doesn't have certain information (e.g., capital, currency, language), the application handles it gracefully
- The server runs on port 3000 by default
Project: Capstone Project - Using Public APIs
Course: Udemy Angela Full Stack Program - Section 29