Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Juan : Asynchronous programming : 3 weeks #173

Open
3 of 7 tasks
jialvaradob opened this issue Sep 13, 2023 · 2 comments
Open
3 of 7 tasks

Juan : Asynchronous programming : 3 weeks #173

jialvaradob opened this issue Sep 13, 2023 · 2 comments
Assignees
Labels
check-in You can use the check-in template to track your module learning objectives, your weekly progress checked-1 After review, we add the checked label checked-2 week_1 week-2 week-3

Comments

@jialvaradob
Copy link
Contributor

jialvaradob commented Sep 13, 2023

My stopwatch preview

Learning Objectives

  • You understand the JavaScript Event Loop, and can demonstrate this by using setTimeout and setInterval to schedule simple tasks.
  • You can explain why Asynchronous Programming is important for programs that have blocking and non-blocking tasks.
  • You can explain the basics of the Client/Server model and HTTP requests and can fetch data from RESTful APIs.
  • You can break down an asynchronous problem into smaller tasks and solve it using promises. This includes identify which tasks depend on each other and which are independent:
    • dependent tasks: The return value from one task is required to start the next task, these must be completed in a specific order - .then
    • independent tasks: These tasks do not use each other's return values, they can be completed at the same time - Promise.allsystem.
  • You can fetch data from an API and render it into the DOM using /api-calls, /handlers and async/await syntax.
  • You can write unit tests for functions that return promises using async/await syntax.

Week 1

I Need Help With:

  • Everything is good for now.

What went well?

  • Understood stack queue concepts.
  • Could tell the difference between synchronous and asynchronous processes.
  • Understood the call stack mechanism and how it serves a great purpose when calling functions asynchronously.
  • At the same time used them for this week project.

What went less well?

  • Took a long time to understand these concepts as they can be confused with past concepts (listeners, handlers).
  • Have to put them in practice which was difficult outside

Lessons Learned

  • Once we use these concepts in a backend environment they'll become clearer.

Sunday Prep Work

  • Keep working on the project

Week 2

I Need Help With:

  • I'm struggling to use functions inside promises as I don't understand the structure very well.

What went well?

What went less well?

Lessons Learned

Sunday Prep Work

Finishing the project.
Doing as many exercises as possible.

Week 3

I Need Help With:

  • Nothing so far.

What went well?

  • I could do the basic function of the project.
  • Understood what is the difference between two ways of writing the same promise handling.
  • Uses of async and await
  • general syntax of promises and how they work,

What went less well?

  • Time constraints were keeping me from polishing the project and adding test cases.
  • The scope was to make at least 2 apps and i only finished one.
  • The functionality could be better.

Lessons Learned

  • Keep practicing the best way to make fetching more readable.
  • Study more the GET, REQUEST

Sunday Prep Work

Courage

---- END CHECK-IN TEMPLATE ---->

@jialvaradob jialvaradob added the check-in You can use the check-in template to track your module learning objectives, your weekly progress label Sep 13, 2023
@jialvaradob jialvaradob self-assigned this Sep 13, 2023
@sammou00 sammou00 changed the title Your Name: module name, number of weeks in this module Juan : Asynchronous programming : 3 weeks Sep 16, 2023
@sammou00 sammou00 added checked-1 After review, we add the checked label checked-2 and removed week-1 week-2 labels Sep 16, 2023
@sammou00
Copy link
Contributor

@jialvaradob

const getUsers = () => {
    return fetch(`https://jsonplaceholder.typicode.com/users`)
        .then((res) => {
            if (!res.ok) {
                throw new Error(
                    `Failed to fetch users with status: ${res.status}`,
                );
            }
            return res.json(); // convert the response to a JavaScript object
        })

        .catch((Error) => {
            console.error(err);
            return null;
        });
};

const needData = (data) => {};

const HandlerUser = () => {
    getUsers().then((data) => {
        console.log(data); // you will get here what ever the first then return so in this case data
        // here you can do whatever you want with your data , you can loop throw them because they are an array in this case
        // you can pass them to another function if you want to
        needData(data);
    });
};

HandlerUser();

@sammou00
Copy link
Contributor

please check my gitHub account you will find more than 7 projects all about fetching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
check-in You can use the check-in template to track your module learning objectives, your weekly progress checked-1 After review, we add the checked label checked-2 week_1 week-2 week-3
Projects
None yet
Development

No branches or pull requests

2 participants