Last active
April 23, 2021 20:56
-
-
Save yann-yinn/1a9ec1cc286d69bc11e1fa31db8caed8 to your computer and use it in GitHub Desktop.
codetree-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
import ReactDOM from "react-dom"; | |
import axios from "axios"; | |
export default function App() { | |
const [users, setUsers] = useState(null); | |
useEffect(async () => { | |
const result = await axios("https://gorest.co.in/public-api/users"); | |
setUsers(result.data.data); | |
}, []); | |
if (users === null) { | |
return "loading users..."; | |
} | |
return ( | |
<div> | |
{users.map((user) => { | |
return <div>{user.name}</div>; | |
})} | |
</div> | |
); | |
} | |
const rootElement = document.getElementById("root"); | |
ReactDOM.render(<App />, rootElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment