You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,30 @@ feedparser.on('readable', function () {
62
62
63
63
```
64
64
65
+
You can also consume feeds using async iteration:
66
+
67
+
```js
68
+
69
+
var FeedParser =require('feedparser');
70
+
var fetch =require('node-fetch');
71
+
72
+
asyncfunctionmain() {
73
+
var res =awaitfetch('http://somefeedurl.xml');
74
+
if (res.status!==200) thrownewError('Bad status code');
75
+
76
+
var feedparser =newFeedParser([options]);
77
+
feedparser.on('error', function (error) { throw error; });
78
+
res.body.pipe(feedparser);
79
+
80
+
forawait (varitemoffeedparser) {
81
+
console.log(item.title);
82
+
}
83
+
}
84
+
85
+
main();
86
+
87
+
```
88
+
65
89
You can also check out this nice [working implementation](https://github.com/scripting/feedRead) that demonstrates one way to handle all the hard and annoying stuff. :smiley:
0 commit comments