Skip to content

Commit 9bfa198

Browse files
committed
README: add LimitRate
1 parent 12f07fe commit 9bfa198

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Or manually:
3939
```html
4040
<script
4141
type="text/javascript"
42-
src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js">
43-
</script>
42+
src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js"
43+
></script>
4444
<script type="text/javascript">
4545
(function () {
4646
emailjs.init({
@@ -120,18 +120,30 @@ The local parameter will have higher priority than the global one.
120120
| publicKey | String | | The public key is required to invoke the method. |
121121
| blockHeadless | Boolean | False | Method will return error 451 if the browser is headless. |
122122
| blockList | BlockList | | Block list settings. |
123+
| limitRate | LimitRate | | Limit rate configuration. |
123124

124125
**BlockList**
125126

126127
Allows to ignore a method call if the watched variable contains a value from the block list.
127128
\
128-
Method will return error 403 if request is blocked.
129+
The method will return the error 403 if the request is blocked.
129130

130131
| Name | Type | Description |
131132
| ------------- | -------- | -------------------------------------------------- |
132133
| list | String[] | The array of strings contains values for blocking. |
133134
| watchVariable | String | A name of the variable to be watched. |
134135

136+
**LimitRate**
137+
138+
Allows to set the limit rate for calling a method.
139+
\
140+
If the request hits the limit rate, the method will return the error 429.
141+
142+
| Name | Type | Default | Description |
143+
| -------- | ------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
144+
| id | String | page path | The limit rate is per page by default. To override the behavior, set the ID. It can be a custom ID for each page, group, or application. |
145+
| throttle | Number | | _(ms)_ After how many milliseconds a next request is allowed. |
146+
135147
**Declare global settings**
136148

137149
```js
@@ -143,6 +155,9 @@ emailjs.init({
143155
blockList: {
144156
list: ['foo@emailjs.com', 'bar@emailjs.com'],
145157
},
158+
limitRate: {
159+
throttle: 10000, // 10s
160+
},
146161
});
147162
```
148163

@@ -162,6 +177,9 @@ emailjs
162177
blockList: {
163178
watchVariable: 'userEmail',
164179
},
180+
limitRate: {
181+
throttle: 0, // turn off the limit rate for these requests
182+
},
165183
})
166184
.then(
167185
(response) => {

0 commit comments

Comments
 (0)