1.3.0 • Published 5 years ago

newsapi.js v1.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

newsapi.js

newsapi.js is a TypeScript (and plain JS) library for newsapi.org.

How do I use this thing?

Just run:

npm install newsapi.js -s

And some examples:

const news = require("newsapi.js");

// For TypeScript: import {NewsAPIClient} from "newsapi.js"

const sources = news.getSources()
    .then(source => console.log(sources)) // Wouldn't do this if I were you
    .catch((err) => console.error(err));

const topHeadlines = news.getTopHeadlines()
    .then(headline => {
        const articles = headline.articles;
        console.log(articles[0].title);
    });

How do I contribute?

Just create a PR! Testing information is below:

How to test this library.

All the hard Mocha & TypeScript work is done for you. But you need to provide yourself a token from here: https://newsapi.org/account.

Once you have received a token, create a file at src/test/config/test.config.json with the following content:

{
    "token": "token here"
}

While replacing the string token here with your token. Then run the following:

$ npm install

and to test:

$ npm test

Licence

We abide by the MIT license.

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago