Skip to content

Commit 18610fc

Browse files
committed
set fetch for repo json
1 parent 2f96073 commit 18610fc

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

Diff for: .env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
GIT_REPO_TOKEN=token-for-repo
1+
REACT_APP_DATA_DIR_URL=https://api.github.com/repos/ezy/code-coverage-dashboard/contents/src/data

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# misc
1313
.DS_Store
14+
.env
1415
.env.local
1516
.env.development.local
1617
.env.test.local

Diff for: config/env.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function getClientEnvironment(publicUrl) {
7676
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
7777
// This should only be used as an escape hatch. Normally you would put
7878
// images into the `src` and `import` them in code to get their paths.
79-
PUBLIC_URL: publicUrl,
79+
PUBLIC_URL: publicUrl
8080
}
8181
);
8282
// Stringify all values so we can feed into Webpack DefinePlugin

Diff for: package.json

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"extract-text-webpack-plugin": "3.0.2",
3939
"file-loader": "1.1.5",
4040
"fs-extra": "3.0.1",
41-
"glob": "^7.1.2",
4241
"html-webpack-plugin": "2.29.0",
4342
"jest": "20.0.4",
4443
"object-assign": "4.1.1",

Diff for: public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
88
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
99
<link href="https://fonts.googleapis.com/css?family=Libre+Franklin:200,400,700,800" rel="stylesheet">
10-
<title>Code Copverage Dashboard</title>
10+
<title>Code Coverage Dashboard</title>
1111
</head>
1212
<body>
1313
<noscript>

Diff for: src/templates/App.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,26 @@ import LineChart from '../components/LineChart';
55
import StackChart from '../components/StackChart';
66
import { Grid, Row, Col } from 'react-flexbox-grid';
77

8+
const directoryUrl = process.env.REACT_APP_DATA_DIR_URL;
9+
let apiData;
10+
811
class App extends Component {
12+
constructor(props) {
13+
super(props);
14+
this.state = { data: null };
15+
}
16+
componentDidMount() {
17+
fetch(directoryUrl).then((res) => {
18+
return res.json();
19+
}).then((responseJson) => {
20+
apiData = responseJson[0].download_url;
21+
fetch(apiData).then((res) => {
22+
return res.json();
23+
}).then((res) => {
24+
this.setState({ data: res })
25+
}).catch((error) => console.error(error));
26+
}).catch((error) => console.error(error));
27+
}
928
render() {
1029
return (
1130
<Grid fluid className="App">
@@ -18,7 +37,7 @@ class App extends Component {
1837
</Row>
1938
<Row>
2039
<Col sm={12}>
21-
<LineChart />
40+
<LineChart data={this.state.data} />
2241
</Col>
2342
</Row>
2443
<Row>

0 commit comments

Comments
 (0)