Skip to content

Commit def745e

Browse files
Merge pull request PrinceSumberia#37 from PrinceSumberia/testing-error
Change api endpoint
2 parents 7cd129f + c797747 commit def745e

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

src/components/CovidApp.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,20 @@ class CovidApp extends Component {
7373

7474
async fetchData() {
7575
this.setState({ isLoading: !this.state.isLoading });
76-
const countryData = axios.get('https://api.covid19india.org/data.json');
76+
const countryData = axios.get('https://data.covid19india.org/data.json');
7777
const districtLevel = axios.get(
78-
'https://api.covid19india.org/v2/state_district_wise.json'
78+
'https://data.covid19india.org/v2/state_district_wise.json'
7979
);
8080
const stateChanges = axios.get(
81-
'https://api.covid19india.org/states_daily.json'
81+
'https://data.covid19india.org/states_daily.json'
8282
);
8383
const updates = axios.get(
84-
'https://api.covid19india.org/updatelog/log.json'
84+
'https://data.covid19india.org/updatelog/log.json'
8585
);
8686

8787
axios.all([countryData, districtLevel, stateChanges, updates]).then(
8888
axios.spread((...responses) => {
89+
console.log(responses);
8990
const countryData = responses[0].data;
9091
const districtLevel = responses[1].data;
9192
const updates = responses[3].data;

src/components/Help.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import React, { Component } from "react";
2-
import axios from "axios";
3-
import FadeIn from "react-fade-in";
4-
import { withStyles } from "@material-ui/styles";
5-
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons";
6-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1+
import React, { Component } from 'react';
2+
import axios from 'axios';
3+
import FadeIn from 'react-fade-in';
4+
import { withStyles } from '@material-ui/styles';
5+
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons';
6+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
77

8-
import Form from "./Form";
9-
import Placeholder from "./Placeholder";
8+
import Form from './Form';
9+
import Placeholder from './Placeholder';
1010

11-
import styles from "../styles/HelpStyles";
11+
import styles from '../styles/HelpStyles';
1212

1313
class Help extends Component {
1414
constructor(props) {
1515
super(props);
1616
this.state = {
17-
query: "",
17+
query: '',
1818
data: {},
1919
currentResources: [],
2020
loadingStatus: null,
@@ -31,21 +31,21 @@ class Help extends Component {
3131
async fetchResources() {
3232
try {
3333
const [response] = await Promise.all([
34-
axios.get("https://api.covid19india.org/resources/resources.json"),
34+
axios.get('https://data.covid19india.org/resources/resources.json'),
3535
]);
3636
const hashmap = {};
3737
response.data.resources.forEach((x) => {
38-
if (typeof hashmap[x["state"]] === "undefined")
39-
hashmap[x["state"]] = {};
40-
if (typeof hashmap[x["state"]][x["city"]] === "undefined")
41-
hashmap[x["state"]][x["city"]] = {};
38+
if (typeof hashmap[x['state']] === 'undefined')
39+
hashmap[x['state']] = {};
40+
if (typeof hashmap[x['state']][x['city']] === 'undefined')
41+
hashmap[x['state']][x['city']] = {};
4242

4343
if (
44-
typeof hashmap[x["state"]][x["city"]][x["category"]] === "undefined"
44+
typeof hashmap[x['state']][x['city']][x['category']] === 'undefined'
4545
)
46-
hashmap[x["state"]][x["city"]][x["category"]] = [];
47-
if (Array.isArray(hashmap[x["state"]][x["city"]][x["category"]]))
48-
hashmap[x["state"]][x["city"]][x["category"]].push(x);
46+
hashmap[x['state']][x['city']][x['category']] = [];
47+
if (Array.isArray(hashmap[x['state']][x['city']][x['category']]))
48+
hashmap[x['state']][x['city']][x['category']].push(x);
4949
});
5050
this.setState({ data: hashmap });
5151
} catch (err) {}
@@ -56,7 +56,7 @@ class Help extends Component {
5656
}
5757

5858
handleLoading() {
59-
this.setState({ loadingStatus: "loading" });
59+
this.setState({ loadingStatus: 'loading' });
6060
}
6161

6262
getData() {
@@ -73,7 +73,7 @@ class Help extends Component {
7373
}
7474
}
7575
this.setState({ currentResources: resources });
76-
setTimeout(() => this.setState({ loadingStatus: "completeLoading" }), 2000);
76+
setTimeout(() => this.setState({ loadingStatus: 'completeLoading' }), 2000);
7777
}
7878

7979
render() {
@@ -128,14 +128,14 @@ class Help extends Component {
128128
handleQuery={this.handleQuery}
129129
handleLoading={this.handleLoading}
130130
/>
131-
{this.state.loadingStatus === "loading" && (
131+
{this.state.loadingStatus === 'loading' && (
132132
<div className={classes.container}>
133133
<Placeholder />
134134
<Placeholder />
135135
<Placeholder />
136136
</div>
137137
)}
138-
{this.state.loadingStatus === "completeLoading" && (
138+
{this.state.loadingStatus === 'completeLoading' && (
139139
<div className={classes.container}>{res}</div>
140140
)}
141141
</div>

0 commit comments

Comments
 (0)