G

Untitled

public
Guest Jun 13, 2024 Never 18
Clone
Plaintext paste1.txt 55 lines (43 loc) | 1.11 KB
1
import React, { useEffect, useState } from 'react'
2
import axios from 'axios';
3
4
5
const CovidReport = () => {
6
const[data,setData]= useState([]);
7
8
useEffect(() =>{
9
console.log("using useEffect")
10
getData();
11
},[])
12
13
const getData =async () =>{
14
try{
15
const response= await axios.get('https://data.covid19india.org/v4/min/data.min.json')
16
setData(response.data)
17
console.log(data)
18
}catch(err){
19
console.log(err)
20
}
21
22
}
23
return (
24
<div>CovidReport</div>
25
)
26
}
27
28
export default CovidReportimport React, { useEffect, useState } from 'react'
29
import axios from 'axios';
30
31
32
const CovidReport = () => {
33
const[data,setData]= useState([]);
34
35
useEffect(() =>{
36
console.log("using useEffect")
37
getData();
38
},[])
39
40
const getData =async () =>{
41
try{
42
const response= await axios.get('https://data.covid19india.org/v4/min/data.min.json')
43
setData(response.data)
44
console.log(data)
45
}catch(err){
46
console.log(err)
47
}
48
49
}
50
return (
51
<div>CovidReport</div>
52
)
53
}
54
55
export default CovidReport