<div id="root"></div>
body {
	padding: 2rem 2rem 4rem;
}
ul {
    display: block;
    list-style-type: disc;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    padding-inline-start: 40px;
}
h2 {
	display: block;
    font-size: 1.17em;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    font-weight: bold;
}
h3 {
	display: block;
    font-size: 1em;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    font-weight: bold;
}
table {
    margin-top: 1rem;
    margin-bottom: 1rem;
}
table thead {
    background-color: #f2f2f2;
    text-align: left;
}

label {
    display: block;
    margin-right: 0.5rem;
}
select {
    border-radius: 2px;
    padding: 0.75rem 1rem;
    -moz-appearance: none;
    -webkit-appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    -ms-appearance: none;
    appearance: none;
	background: transparent;
	background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
	background-repeat: no-repeat;
	background-position-x: 98%;
	background-position-y: 12px;
	border: 1px solid #ccc;	
	width: 320px;
}
option {
	width: 100%;
    border-radius: 10px;
    padding: 1rem;
}
.box {
	margin: 0rem auto 3rem auto
}
View Compiled
const { Component, CSSProperties, useEffect, useState, useCallback } = React;

const App = () => {
    const [data1, setData1] = useState(null);

    useEffect(() => {
        const fetchData = async () => {
          try {
            // Fetch users
            const usersResponse = await fetch(
              'https://jsonplaceholder.typicode.com/users'
            )
            const users = await usersResponse.json()

            // Fetch posts for each user
            const usersWithPosts = await Promise.all(
              // Map tree data
              users.map(async (user) => {
                const postsResponse = await fetch(
                  `https://jsonplaceholder.typicode.com/posts?userId=${user.id}`
                )
                const posts = await postsResponse.json()
                return { ...user, posts }
              })
            )

            setData1(usersWithPosts)
          } catch (error) {
            console.error('Error fetching data:', error)
          }
        }

        fetchData()
    }, []); // Empty dependency array means this effect runs once after the initial render

    // Render the component with the fetched data
    return (
        <div className="box">
            <h1>Data from Endpoint 1:</h1>
            <pre>{JSON.stringify(data1, null, 2)}</pre>
        </div>
    );
};

ReactDOM.render(<App />, document.getElementById("root"));
View Compiled

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.6/umd/react-dom.production.min.js
  3. https://unpkg.com/@types/react@16.8.6/index.d.ts
  4. https://unpkg.com/@types/react-dom@16.8.6/index.d.ts
  5. https://unpkg.com/@types/react-dom@16.8.4/index.d.ts