Skip to content

Commit

Permalink
Fetch and a Jokes Component
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Oct 19, 2022
1 parent bd64536 commit a12f7ba
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 20 deletions.
Binary file modified portfolio/.parcel-cache/data.mdb
Binary file not shown.
114 changes: 95 additions & 19 deletions portfolio/dist/index.975ef6c8.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion portfolio/dist/index.975ef6c8.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions portfolio/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import Projects from './Projects';
import SocialProfiles from './SocialProfiles';
import Title from './Title';
import Jokes from './Jokes';
import profile from '../assets/profile.png';

class App extends Component {
Expand Down Expand Up @@ -37,6 +38,8 @@ class App extends Component {
<Projects />
<hr />
<SocialProfiles />
<hr />
<Jokes />
</div>
);
}
Expand Down
24 changes: 24 additions & 0 deletions portfolio/src/components/Jokes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { Component } from 'react';

class Jokes extends Component {
state = { joke: {} };

componentDidMount() {
fetch('https://official-joke-api.appspot.com/random_joke')
.then(response => response.json())
.then(json => this.setState({ joke: json }));
}

render() {
const { setup, punchline } = this.state.joke;

return (
<div>
<h2>Highlighted Joke</h2>
<p>{setup} <em>{punchline}</em></p>
</div>
)
}
}

export default Jokes;

0 comments on commit a12f7ba

Please sign in to comment.