React Fundamentals

0% completed

Previous
Next
Code Challenge

Challenge: Create a Data Fetching custom hook

Follow these instructions to complete your challenge:

  1. Create a custom hook called useFetch.
  2. The hook should accept a URL as an argument and fetch data from that URL.
  3. It should return loading state, error state, and data.
  4. Use this hook inside the App component to fetch data from https://jsonplaceholder.typicode.com/posts/1.
  5. Display "Loading..." while fetching and show the title of the fetched post once the request is complete.
  6. If an error occurs, display "An error occurred!".

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next