Skip to content

Fetch todos from JSONPlaceholder in App #53

@kossa21

Description

@kossa21

Use fetch and useEffect in App to load todos from the JSONPlaceholder API.

API endpoint

  • https://jsonplaceholder.typicode.com/todos

Acceptance criteria

  • In App.tsx, import useEffect and mapTodoToTicket.
  • Initialize tickets as an empty array:
    • const [tickets, setTickets] = useState<Ticket[]>([]);
  • Add a useEffect with [] as dependency array that:
    • Sets isLoading to true.
    • Calls fetch('https://jsonplaceholder.typicode.com/todos').
    • Converts the response to JSON.
    • Takes only the first ~15 todos: todos.slice(0, 15).
    • Maps them with mapTodoToTicket.
    • Calls setTickets(mappedTickets).
    • In case of error, sets error to a friendly message like 'Failed to load tickets'.
    • In finally (or after both success/error paths), sets isLoading back to false.
  • Confirm in the UI that the board now uses API data instead of mockData.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions