Skip to content

Instantly share code, notes, and snippets.

@yann-yinn
Last active April 23, 2021 20:56
Show Gist options
  • Save yann-yinn/1a9ec1cc286d69bc11e1fa31db8caed8 to your computer and use it in GitHub Desktop.
Save yann-yinn/1a9ec1cc286d69bc11e1fa31db8caed8 to your computer and use it in GitHub Desktop.
codetree-test
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