Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Task 9: API fetching #77

Open
PradyumnaKrishna opened this issue May 18, 2023 · 1 comment
Open

Task 9: API fetching #77

PradyumnaKrishna opened this issue May 18, 2023 · 1 comment

Comments

@PradyumnaKrishna
Copy link
Member

PradyumnaKrishna commented May 18, 2023

This task is API fetching a helper code is provided below to ease your task.

Task
Create a html file task9.html that consist of a profile page of user having.

  • A profile avatar, name and bio below the avatar.
  • Followed by other details containing age, gender, email, location, occupation, and hobbies.
  • Add appropriate styling according to your personal preference.

Script
All details must be fetched from the API that has the URL https://cc-bhu.github.io/web-development/assets/api/person.json.
This code block might assist you.

// Fetch is a method to perform API call
fetch(url)
.then(response => response.json())
.then(data => {
    // Get element and change its innerHTML, use `data.name` or `data["name"]`.
    document.getElementById("name").innerHTML = data["name"];
});

To debug, you can use console.log(data); to log the data in developer tools -> console.

Demo
Demo

Resources

@PradyumnaKrishna
Copy link
Member Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant