I'm currently developing a MEAN stack application using Angular 2.
Despite finding similar inquiries on StackOverflow, I've explored various solutions without success. While many suggest importing the entire rx/js library along with map or using:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
However, none of these configurations seem to resolve the issue for me. The error persists when using .map in my service. I attempted updating both global typescript and the version specified in dependencies but encountered the same error post 'ng serve'. It appears to be a typescript-related problem, though it remains ambiguous since importing observables did not fix it.
Package.json
{
"name": "aether-news",
"version": "0.0.0",
"license": "MIT",
... (omitted for brevity)
}
Imports in my service
import { Injectable } from '@angular/core';
... (imports omitted for brevity)
import 'rxjs/add/operator/map';
Service Code
import { Injectable } from '@angular/core';
... (imports and code omitted for brevity)
@Injectable()
export class NewsApiService {
... (properties and methods omitted for brevity)
//EVENT REGISTRY
//BBC
getEventRegistryBBC(){
return this.http.get("http://eventregistry.org/json/article?sourceUri=bbc.co.uk&sourceUri=bbc.com&categoryUri=dmoz%2FSociety%2FPolitics&action=getArticles&articlesSortBy=date&resultType=articles&articlesCount=200&articlesIncludeArticleDuplicateList=true&articlesIncludeArticleCategories=true&articlesIncludeConceptImage=true&articlesIncludeConceptDescription=true&articlesIncludeConceptDetails=true&articlesIncludeConceptTrendingScore=true&articlesIncludeSourceDescription=true&articlesIncludeArticleImage=true&articlesIncludeSourceDetails=true")
.map((res) => {
this.eventRegistryBBC = res.json()
return res.json().articles.results;
})
}
Please share if you've encountered a similar issue despite correctly importing rxjs library. Thanks for your help.