yogeshtakeo / task_BFD30

Task repo for BFD30
0 stars 0 forks source link

Task 9: Handling Promises with JSONPlaceholder API Endpoint #1

Open yogeshtakeo opened 1 year ago

yogeshtakeo commented 1 year ago

Task 9: Handling Promises with JSONPlaceholder API Endpoint

Objective:

Practice handling promises by making API requests to the JSONPlaceholder API endpoint.

Task Overview

Understand promises and their role in asynchronous JavaScript. Make HTTP requests to the JSONPlaceholder API endpoint using fetch(). Handle promise resolution and rejection using then() and catch() methods. Extract and display relevant data from the API response.

Task Details

Understanding Promises:

Review the concept of promises in JavaScript. Understand the role of promises in handling asynchronous operations.

Explore JSONPlaceholder API:

Visit the JSONPlaceholder website: https://jsonplaceholder.typicode.com/ Familiarize yourself with the available API endpoints and the data they provide. Select an endpoint to work with for this task (e.g., /users, /posts, /comments, etc.).

Make API Request and Handle Promise:

Open a new JavaScript file in your project (e.g., api.js or any other file you create). Use the fetch() function to make a GET request to the chosen API endpoint. Handle the promise returned by fetch() using the then() and catch() methods. Extract the response data (JSON) from the resolved promise using the json() method. Display the response data (e.g., log it to the console or render it on a web page).

Handle Promise Rejection:

Simulate an error by modifying the API endpoint URL or introducing a network issue. Handle the rejected promise using the catch() method. Display an error message to indicate the failed API request.

Test and Refine:

Open your project in a browser or run your JavaScript file using Node.js. Verify that the API request is successful and the response data is correctly displayed. Test the error handling by introducing a deliberate error and checking if the error message is displayed.

Task Submission

  1. Take a screenshot of the web browser displaying the rendered React component .
  2. Share the screenshot
  3. Optionally, submit the code files (App.js and any other relevant files) for review with the GitHub Repositary.
Namsla commented 1 year ago

Namkhang Tsamchoe Git URL:https://github.com/Namsla/Task9.git

Screen Shot 2023-06-01 at 11 51 40 AM Screen Shot 2023-06-01 at 11 25 42 AM Screen Shot 2023-06-01 at 11 39 46 AM
babisha commented 1 year ago

Babisha Manandhar Github Url: https://github.com/yogeshtakeo/task_BFD30.git

Image Image Image

KabinaThapa commented 1 year ago

Kabina Thapa https://github.com/yogeshtakeo/task_BFD30/tree/kabinathapa

Image Image Image Image

ashmaupret100 commented 1 year ago

Name: Ashma Upreti

Image

Image

sandessth commented 1 year ago

Name: Sandesh Shrestha Git URL: https://github.com/yogeshtakeo/task_BFD30/tree/Sandesh/handling-promise code no error frontpage no error git

Console with error when wrong URL provided:

frontpage with error

Jharanatmg commented 1 year ago

Jharana Github url - https://github.com/yogeshtakeo/task_BFD30.git

Image

Image

Image

junuthapa011 commented 1 year ago

Name: Junu Thapa Github URL: https://github.com/yogeshtakeo/task_BFD30/tree/junu image image

dinakc commented 1 year ago

Deena KC https://github.com/yogeshtakeo/task_BFD30.git

Image Image

sdhital12 commented 1 year ago
Screen Shot 2023-07-24 at 10 45 55 PM Screen Shot 2023-07-24 at 10 52 10 PM
sdhital12 commented 1 year ago

Name: sita Dhital GitUrl: https://github.com/sdhital12/task-9.git