Skip to content

finished #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</html>
23 changes: 20 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="App">
<h1 className="Header">Characters</h1>
{stars.map(star => {
return <Character name={star.name} />;
})}
</div>
);
}

};

export default App;
1 change: 1 addition & 0 deletions src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ describe("<App />", () => {
expect(await screen.findByText(/Owen/i)).toBeInTheDocument();
});
});

44 changes: 43 additions & 1 deletion src/components/Character.js
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
// Write your Character component here
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Characters React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
2 changes: 1 addition & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ body {
font-family: sans-serif;
background-image: url('./images/sw-bg.jpg');
background-size: cover;
}
}
1 change: 1 addition & 0 deletions src/mocks/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ import { handlers } from "./handlers";

// This configures a Service Worker with the given request handlers.
export const worker = setupWorker(...handlers);
``