Socket
Socket
Sign inDemoInstall

angular-news-api

Package Overview
Dependencies
14
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angular-news-api

This Library provides everything you need to use the NewsAPI from you Angular app the way it should be: using Observables, Types and Dependency Injection.


Version published
Weekly downloads
2
Maintainers
1
Install size
1.54 MB
Created
Weekly downloads
 

Readme

Source

NewsAPI - An Angular Interface for NewsAPI

This Library provides everything you need to use the NewsAPI from you Angular app the way it should be: using Observables, Types and Dependency Injection.

Installing in your project

npm install --save angular-news-api

Using in your Angular application

Import the AppRoutingModule into your app module and configure your API Key:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { NgnewsModule } from 'angular-news-api';
import { NewsApiKeyConfig } from 'angular-news-api';

const newsApiConfig: NewsApiKeyConfig = {
  key: 'API_KEY_FROM_NEWS_API'
};

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgnewsModule.forRoot(newsApiConfig)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Now you can use all the endpoints of the API:

constructor(private newsApiService: NewsApiService) {}

topHeadlines() {
 this.newsApiService.topHeadlines({
       sources: 'bbc-news,the-verge'
     }).subscribe(data => console.log(data));
}

everything() {
 this.newsApiService.everything({
       q: 'trump'
     }).subscribe(data => console.log(data));
}

sources() {
 this.newsApiService.sources({
       country: 'us'
     }).subscribe(data => console.log(data));
}

Check the official documentation for more info about the options in each endpoint.

Keywords

FAQs

Last updated on 28 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc