Skip to content

Commit a25a10f

Browse files
committed
added fetch
1 parent fbf2a89 commit a25a10f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/routes/home/Home.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ import { EventSeat } from "@material-ui/icons";
33
import "./Home.css";
44

55
class Home extends Component {
6+
componentDidMount() {
7+
return fetch("https://alpaca-backend.herokuapp.com/get-stocks", {
8+
method: "GET",
9+
headers: {
10+
Accept: "application/json",
11+
"Content-Type": "application/json"
12+
}
13+
})
14+
.then(async response => {
15+
console.log("res", response);
16+
const data = await response.json();
17+
console.log("result is", JSON.stringify(data));
18+
return data;
19+
})
20+
.catch(err => {
21+
console.log("API call error:", err);
22+
return err;
23+
});
24+
}
25+
626
render() {
727
return (
828
<div className="homeContainer">

0 commit comments

Comments
 (0)