Skip to content

yashpatel-py/News-Star-React

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News Website

Get API KEY

  1. Go to https://newsapi.org/
  2. Login or create an account
  3. Then click on your email-ID from navbar and you will be redirected to your account page and from there you can copy your API KEY.

Setup project

  1. Once you get API KEY you need yo add that key in src/components/News.js file.
// Replace <API KEY> to your key and make sure to remove <> brackets.
    async componentDidMount() {
        let url = "https://newsapi.org/v2/top-headlines?country=in&apiKey=<API KEY>&page=1";
        let data = await fetch(url);
        let parsedData = await data.json()
        console.log(parsedData);
        this.setState({articles: parsedData.articles})
    }
  1. Run command npm install in terminal.
  2. Then run the command npm start in terminal.

About

This app is basic react app which will display news

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published