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
+79-25Lines changed: 79 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -30,18 +30,14 @@ read(url).then((feed) => {
30
30
})
31
31
```
32
32
33
-
##### Note:
34
-
35
-
> Since Node.js v14, ECMAScript modules [have became the official standard format](https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_modules_ecmascript_modules).
36
-
> Just ensure that you are [using module system](https://nodejs.org/api/packages.html#determining-module-system) and enjoy with ES6 import/export syntax.
37
-
38
-
39
33
## APIs
40
34
41
35
-[.read(String url)](#readstring-url)
36
+
-[The events](#the-events)
37
+
-[.resetEvents()](#reset-event-listeners)
42
38
-[Configuration methods](#configuration-methods)
43
39
44
-
####read(String url)
40
+
### read(String url)
45
41
46
42
Load and extract feed data from given RSS/ATOM source. Return a Promise object.
47
43
@@ -55,9 +51,10 @@ import {
55
51
constgetFeedData=async (url) => {
56
52
try {
57
53
console.log(`Get feed data from ${url}`)
58
-
constdata=awaitread(url)
59
-
console.log(data)
60
-
return data
54
+
constresult=awaitread(url)
55
+
// result may be feed data or null
56
+
console.log(result)
57
+
return result
61
58
} catch (err) {
62
59
console.trace(err)
63
60
}
@@ -89,27 +86,84 @@ Feed data object retuned by `read()` method should look like below:
89
86
}
90
87
```
91
88
92
-
#### Configuration methods
89
+
###The events
93
90
94
-
In addition, this lib provides some methods to customize default settings. Don't touch them unless you have reason to do that.
91
+
Since v6.0.0, `feed-reader` supports event-driven pattern for easier writing code with more control.
95
92
96
-
- getRequestOptions()
97
-
- setRequestOptions(Object requestOptions)
93
+
-`onSuccess(Function callback)`
94
+
-`onError(Function callback)`
95
+
-`onComplete(Function callback)`
98
96
99
-
#### Object `requestOptions`:
97
+
The following example will explain better than any word:
100
98
101
99
```js
102
-
{
103
-
headers: {
104
-
'user-agent':'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0'
0 commit comments