Create a component that fetches and displays a list of hardcoded items from a mock API.
MediumProblem Statement
Create a component that fetches and displays a list of hardcoded items from a mock API.
Sample Input
[{ "id": 1, "title": "Item 1" }, { "id": 2, "title": "Item 2" }]Sample Output
Item 1 Item 2
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import React, { useState, useEffect } from "react";
const FetchItems = () => {
return (
<div>
{/* Render fetched items here */}
</div>
);
};
export default FetchItems;
Input
[{ "id": 1, "title": "Item 1" }, { "id": 2, "title": "Item 2" }]Expected Output
Item 1 Item 2