Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Start interactive tutorial

← Back to Projects

Todolist Application Using React and Fetch

Difficulty

  • easy

Average duration

8 hrs

Technologies

  • APIs

  • Fetch API

  • React.js

Difficulty

  • easy

Average duration

8 hrs

Technologies

📝 Instructions:

This exercise is meant to be completed after the TODO list React application because the first part is the perfect boilerplate to start using API's.

For this second part, we will sync our to-do list with a real database, using the following RESTful and public API made for this exercise.

🔗 Click here to access to the TODO-list API documentation.

This whole exercise is about asynchronous programming because the interactions from and to the server need to be done async. That way, the user does not have to wait for the information to arrive.

🌱 How to start this project

Do not clone this repository because we are going to be using a different template.

We recommend opening the react boilerplate using a provisioning tool like Codespaces (recommended) or Gitpod. Alternatively, you can clone it on your local computer using the git clone command.

This is the repository you need to open or clone:

1https://github.com/4GeeksAcademy/react-hello

👉 Please follow these steps on how to start a coding project.

💡 Important: Remember to save and upload your code to GitHub by creating a new repository, updating the remote (git remote set-url origin <your new url>), and uploading the code to your new repository using the add, commit and push commands from the git terminal.

📝 Instructions:

  1. Make your TODO List sync with the backend API every time a task is added or deleted.
  2. Add a "clear all tasks" button that will delete the entire list from the server and update the empty list on the front-end.

👉 Key moments for integration:

  1. Load tasks on start (useEffect)

    • Use the GET method specified in the documentation to fetch the list and update the state that holds the task list.
  2. Add a task.

    • Use the POST method specified in the documentation to add a new task and then use GET to update the task list.
  3. Delete a task.

    • Use the DELETE method to remove a task and then GET to update the list.
  4. Make sure to create a user before adding tasks.

💡 Hint:

Use the following fetch call to create a new task on the server. Remember to create a user first.

1fetch('https://playground.4geeks.com/todo/todos/alesanchezr', { 2 method: "POST", 3 body: JSON.stringify(task), 4 headers: { 5 "Content-Type": "application/json" 6 } 7 }) 8 .then(resp => { 9 console.log(resp.ok); // Will be true if the response is successful 10 console.log(resp.status); // Status code 201, 300, 400, etc. 11 return resp.json(); // Will attempt to parse the result to JSON and return a promise where you can use .then to continue the logic 12 }) 13 .then(data => { 14 // This is where your code should start after the fetch is complete 15 console.log(data); // This will print the exact object received from the server to the console 16 }) 17 .catch(error => { 18 // Error handling 19 console.log(error); 20 });

⚠️ For any other request, you must change the variables in the fetch: The URL, the method, and the payload.

This and many other projects are built by students as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sanchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.

Sign up and get access to solution files and videos for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Sign up and get access to solution files and videos for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies