Skip to content

Chloexlsx/WhereToTravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhereToTravel - Destination Generator

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.

🌍 About

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!

✨ Features

  • 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

🛠️ Technologies Used

  • 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

📦 Installation

  1. Clone or download this repository
  2. Navigate to the project directory:
    cd WhereToTravel
  3. Install dependencies:
    npm install

🚀 Usage

  1. Start the server:
    node index.js
  2. Open your browser and navigate to:
    http://localhost:3000
    
  3. Select a continent from the dropdown menu (or leave it as "Random one")
  4. Click "Go" to get a random country suggestion
  5. View the country information displayed on the page

📁 Project Structure

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

🔌 API Information

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.

🎯 How It Works

  1. GET Request (/): On initial page load, fetches a random country from Asia
  2. 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

🎨 Features in Detail

  • 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

👤 Author

Made with ❤️ by Chloe Yang

📝 Notes

  • 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

About

A random country generator based on user selected continent.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors