| 27 | |
| 28 | //componentDidMount always runs after render method |
| 29 | async componentDidMount(){ |
| 30 | //console.log("cdm"); |
| 31 | let url=`https://newsapi.org/v2/top-headlines?country=in&category=${this.props.category}&apiKey=f31900ddb83a4b52bf702e1fe7089003&pageSize=${this.props.pagesize}`; |
| 32 | this.setState({loading:true});//During the time the api is fetching the data then only spinner will be there which will show loading |
| 33 | let data=await fetch(url); |
| 34 | let parsedData=await data.json(); |
| 35 | console.log(parsedData); |
| 36 | this.setState({articles: parsedData.articles, |
| 37 | totalResults: parsedData.totalResults, |
| 38 | loading:false |
| 39 | }); |
| 40 | } |
| 41 | |
| 42 | handlePrevclick=async()=>{ |
| 43 | console.log("Previous"); |