Skip to content

Review of Essential JS for React : Async/ Await Issue #100

@sunil0791

Description

@sunil0791

async function getTodos() {
const res = await fetch("https://jsonplaceholder.typicode.com/todos");
const data = await res.json();
console.log(data);

return data;
}

const todos = await getTodos();

Last line should also have await if not, the console.log in later gets executed first

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions