Skip to content

Instantly share code, notes, and snippets.

@guillaumebdx
Created July 22, 2021 09:35
Show Gist options
  • Save guillaumebdx/7f5a9941795e5e1a153c55aaa5ff9981 to your computer and use it in GitHub Desktop.
Save guillaumebdx/7f5a9941795e5e1a153c55aaa5ff9981 to your computer and use it in GitHub Desktop.
disp
import './App.css';
import axios from "axios";
import DisplayTask from "./components/DisplayTask";
import {useState} from "react";
import {useEffect} from "react";
function App() {
useEffect(() => {
axios.get('https://localhost:8000/api/projects/1/tasks')
.then((response) => response.data)
.then((data) => {
setTasks(data);
});
}, [])
const [tasks, setTasks] = useState(null);
return (
<>
<h1>Task</h1>
{tasks && tasks['hydra:member'].map(task => (
<DisplayTask task={task} />
))}
</>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment