Skip to content

Musira-Hafsa/random-user-api-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

random-user-api-generator

This is a simple web application that fetches a random user from the RandomUser.me API and displays their basic information such as photo, name, email, phone number, and location.

Only female users are displayed based on the filter added in the code.


πŸš€ Features

  • Fetches a random user using fetch() API
  • Displays:
    • πŸ‘€ User Photo
    • πŸ“ Name
    • πŸ“§ Email
    • πŸ“± Phone
    • πŸ“ Location
  • Shows user only if gender = female
  • Simple and clean UI
  • One-button user generator

🎯 How It Works

The app fetches data from:

https://randomuser.me/api/ It extracts the first object from the results array and updates the UI.

fetch('https://randomuser.me/api/')
  .then(res => res.json())
  .then(data => {
      let user = data.results[0];
      if (user.gender === 'female') {
          document.getElementById("photo").src = user.picture.large;
          document.getElementById("name").textContent = user.name.first + " " + user.name.last;
          document.getElementById("email").textContent = user.email;
          document.getElementById("phone").textContent = user.phone;
          document.getElementById("location").textContent = user.location.city + ", " + user.location.country;
      }
  });

  πŸ› οΈ Technologies Used

HTML
CSS
JavaScript
Fetch API
RandomUser.me API

About

A simple Random User Generator app that fetches and displays user details using the RandomUser.me API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published