diff --git a/public/index.html b/public/index.html index cbd4a8a83..23443250e 100644 --- a/public/index.html +++ b/public/index.html @@ -40,4 +40,4 @@ To create a production bundle, use `npm run build` or `yarn build`. --> - + \ No newline at end of file diff --git a/src/App.js b/src/App.js index 5e69e9fdd..0d371901a 100644 --- a/src/App.js +++ b/src/App.js @@ -1,19 +1,36 @@ -import React from 'react'; -import './App.css'; +import React, { useState, useEffect } from "react"; +import axios from "axios"; +import "./App.css"; +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. // Fetch characters from the API in an effect hook. Remember, anytime you have a + const [stars, setStars] = useState([]); + useEffect(() => { + axios + .get(`https://swapi.dev/api/people`) + .then(res => { + console.log(res.data); + setStars(res.data); + }) + .catch(err => console.log(err)); + }, []); + // 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. return (

Characters

+ {stars.map(star => { + return ; + })}
); -} + +}; export default App; diff --git a/src/App.test.js b/src/App.test.js index 4fa3255ed..1ba181eb5 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -43,3 +43,4 @@ describe("", () => { expect(await screen.findByText(/Owen/i)).toBeInTheDocument(); }); }); + diff --git a/src/components/Character.js b/src/components/Character.js index 4083249c0..23443250e 100644 --- a/src/components/Character.js +++ b/src/components/Character.js @@ -1 +1,43 @@ -// Write your Character component here + + + + + + + + + + + + + Characters React App + + + +
+ + + \ No newline at end of file diff --git a/src/index.css b/src/index.css index 5ea3014fb..6558670cd 100644 --- a/src/index.css +++ b/src/index.css @@ -4,4 +4,4 @@ body { font-family: sans-serif; background-image: url('./images/sw-bg.jpg'); background-size: cover; -} +} \ No newline at end of file diff --git a/src/mocks/browser.js b/src/mocks/browser.js index 8ea7c89e1..8626cc887 100644 --- a/src/mocks/browser.js +++ b/src/mocks/browser.js @@ -4,3 +4,4 @@ import { handlers } from "./handlers"; // This configures a Service Worker with the given request handlers. export const worker = setupWorker(...handlers); +`` \ No newline at end of file