forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DevJokes.jsx
42 lines (40 loc) · 1.04 KB
/
DevJokes.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import PlayHeader from "common/playlists/PlayHeader";
import "./devJokes.css";
import axios from "axios";
import { useEffect, useState } from "react";
function DevJokes(props) {
// Your Code Start below.
const [joke, setjoke] = useState([]);
const fetch = () => {
axios
.get("https://backend-omega-seven.vercel.app/api/getjoke")
.then((response) => {
setjoke(response.data);
console.log(response.data);
});
};
useEffect(() => {
fetch();
}, []);
return (
<>
<div className="play-details">
<PlayHeader play={props} />
<div className="maincontanier">
<div className="jokecontanier">
{joke.map((value) => {
return (
<div className="cont2">
<h1>{value.question}</h1>
<p>{value.punchline}</p>
</div>
);
})}
</div>
<button onClick={fetch} className="btn">Next joke</button>
</div>
</div>
</>
);
}
export default DevJokes;