diff --git a/package-lock.json b/package-lock.json index 79208da2a..1ca867df7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "web-sprint-challenge-intro-to-react", "version": "0.1.1", "dependencies": { "@testing-library/jest-dom": "^5.12.0", diff --git a/src/App.css b/src/App.css index fab70641c..4b6af1f54 100644 --- a/src/App.css +++ b/src/App.css @@ -6,3 +6,4 @@ text-shadow: 1px 1px 5px #fff; } /* write your parent styles in here for your App.js */ + diff --git a/src/App.js b/src/App.js index 5e69e9fdd..ac7d571a5 100644 --- a/src/App.js +++ b/src/App.js @@ -1,17 +1,54 @@ -import React from 'react'; -import './App.css'; +import React, {useState, useEffect} from 'react'; +import './App.css' +import axios from 'axios' +import Character from './components/Character' + + +// console.log('data', data) +// data.map(item =>{ +// console.log('hello', item) +// }) const App = () => { + const [character, setCharacter] = useState([]) + + const info= character.map(info => { + return ( info) + }) +// console.log('hello', info) + +useEffect(() => { + axios.get(`https://swapi.dev/api/people`) + .then (res =>{ + setCharacter(res.data) + + }) + .catch (err => console.error(err)) +}, []) + + +character.map(item => { + console.log ('waiting', item) +}) + // Try to think through what state you'll need for this app before starting. Then build out // the state properties here. // 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. - +// console.log(character) +// return (
{`hailing from ${character.homeworld}, ${character.name} is a human with ${character.hair_color} hair, and ${character.eye_color} eyes.`}
*/} +