As someone who is new to Angular and TypeScript, I am finding it challenging to add a 3rd party module or package to my Angular app. After spending hours searching online, I have yet to come across a simple guide for this process.
The specific problem I am facing is related to creating an RSS reader. My research led me to believe that I can achieve this by installing the following npm package:
https://www.npmjs.com/package/rss-to-json
Despite trying various approaches, I have been unsuccessful so far. Below, I have included the latest code from my service:
http-requests.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
import { Feed } from 'rss-to-json';
@Injectable({
providedIn: 'root'
})
export class HttpRequestsService {
constructor(private http: HttpClient) { }
doDummyRequest() {
return Feed.load('https://learnstartup.net/feed/', function(err, rss){
console.log(rss);
});
}
displayDummyRequest() {
this.doDummyRequest().subscribe((data: any) => {
console.log(12346);
console.log(data);
});
}
}
However, this code is generating an error:
RssFeedComponent.ngfactory.js? [sm]:1 ERROR TypeError: Cannot read property 'load' of undefined
at HttpRequestsService.doDummyRequest (http-requests.service.ts:15)
at RssFeedComponent.onDummyButtonClick (rss-feed.component.ts:18)
at Object.eval [as handleEvent] (RssFeedComponent.html:5)
at handleEvent (core.js:43993)
at callWithDebugContext (core.js:45632)
at Object.debugHandleEvent [as handleEvent] (core.js:45247)
at dispatchEvent (core.js:29804)
at core.js:42925
at HTMLButtonElement.<anonymous> (platform-browser.js:2668)
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
Additionally, my IDE (Visual Studio Code) is showing a hint:
Could not find a declaration file for module 'rss-to-json'. '/home/h8machine/App/news-agg/node_modules/rss-to-json/dist/index.js' implicitly has an 'any' type.
Try `npm install @types/rss-to-json` if it exists or add a new declaration (.d.ts) file containing `declare module 'rss-to-json';`ts(7016)
Any assistance would be greatly appreciated.