From 221fdf516eef3c066605e6d0abef64a9e0026549 Mon Sep 17 00:00:00 2001 From: Cassius-Cassity <80988165+Cassius-Cassity@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:49:58 -0600 Subject: [PATCH] Really want to go back over this stuff --- src/App.js | 33 ++++++++++++++++++++++++++++++--- src/components/Character.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 5e69e9fdd..597592bc9 100644 --- a/src/App.js +++ b/src/App.js @@ -1,18 +1,45 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import './App.css'; +import axios from 'axios'; +import Character from './components/Character' + + const App = () => { // Try to think through what state you'll need for this app before starting. Then build out // the state properties here. - + const [Characters, setCharacters] = useState([]) + //const [currentCharacterId, setCurrentCharacterId] =useState(null) + // const [CharactersId, setCharactersId] = useState(null) // Fetch characters from the API in an effect hook. Remember, anytime you have a // side effect in a component, you want to think about which state and/or props it should // sync up with, if any. + + useEffect(()=> { + axios.get('https://swapi.dev/api/people/?format=api') + .then(res=> { + setCharacters(res.data) + + }).catch(err=>{ + console.log(err) + }) + },[]) + + + + return (