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
Optional argument `params` is an object with it we can set `maxwidth` and/or `maxheight` those are used to scale embed size to fit your container size. Please refer [oEmbed/Full Spec/Consumer Request](https://oembed.com/#section2) for more info.
54
+
Load and extract oembed data.
48
55
49
-
Here is how we can use `oembed-parser` in async/await style:
56
+
Example:
50
57
51
58
```js
52
-
import {
53
-
extract
54
-
} from'oembed-parser'
59
+
const { extract } =require('oembed-parser')
55
60
56
61
constgetOembed=async (url) => {
57
62
try {
58
63
constoembed=awaitextract(url)
59
64
return oembed
60
65
} catch (err) {
61
66
console.trace(err)
67
+
returnnull
62
68
}
63
69
}
64
70
65
71
constdata=getOembed('your url')
66
72
console.log(data)
67
73
```
68
74
75
+
Optional argument `params` is an object with it we can set `maxwidth` and/or `maxheight` those are used to scale embed size to fit your container size. Please refer [oEmbed/Full Spec/Consumer Request](https://oembed.com/#section2) for more info.
69
76
70
77
#### .hasProvider(String URL)
71
78
72
-
Return boolean. True if the URL matches with any provider in the list.
79
+
Check if a URL matches with any provider in the list.
List of resource providers is a clone of [oembed.com](http://oembed.com/providers.json) and available [here](https://raw.githubusercontent.com/ndaidong/oembed-parser/master/src/utils/providers.json).
149
+
`oembed-parser` is using [axios]() to send HTTP requests. Please refer [axios' request config](https://axios-http.com/docs/req_config) for more info.
150
+
151
+
Default option:
152
+
153
+
```js
154
+
{
155
+
headers: {
156
+
'user-agent':'Mozilla/5.0 (X11; Linux i686; rv:94.0) Gecko/20100101 Firefox/94.0',
157
+
accept:'application/json; charset=utf-8'
158
+
},
159
+
responseType:'json',
160
+
responseEncoding:'utf8',
161
+
timeout:6e4,
162
+
maxRedirects:3
163
+
}
164
+
```
111
165
112
166
113
167
## Facebook and Instagram
114
168
115
169
Since October 24 2020, Facebook have deprecated their legacy urls and applied a new Facebook oEmbed endpoints.
116
-
Please update your `oembed-parser` version to v1.4.2 or later to be able to extract oembed data from Instagram and Facebook.
117
-
118
-
Technically, now we have to use Facebook Graph API, with the access token from a valid and live Facebook app.
119
170
171
+
Technically, now we have to use Facebook Graph API, with the access token from a valid and live Facebook app. `oembed-parser` will try to get these values from environment variables, so please define them, for example:
0 commit comments