Skip to content

Commit bd7ba06

Browse files
Return a message when a 429 http response is received (#115)
This adds a case for handling 429 responses from Simperium, which has an empty response body, and adds a response text which can then be used to handle this error specifically.
1 parent cc5885d commit bd7ba06

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

RELEASE-NOTES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.1.4
4+
5+
- Adds a message response when receiving a 429 HTTP error [#115](https://github.com/simperium/node-simperium/pull/115)
6+
37
## 1.1.3
48

59
- Fixes a sync issue by reverting the changes from PR #101 [#114](https://github.com/simperium/node-simperium/pull/114)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simperium",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "A simperium client for node.js",
55
"main": "./lib/simperium/index.js",
66
"browser": {

src/simperium/http-request.browser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ export default function(
1010
xhr.open( 'POST', url );
1111
xhr.setRequestHeader( 'X-Simperium-API-Key', apiKey );
1212

13-
xhr.onload = () => resolve( xhr.responseText );
13+
xhr.onload = () => {
14+
if ( xhr.status === 429 && xhr.responseText === '' ) {
15+
return resolve('too many requests');
16+
}
17+
resolve(xhr.responseText);
18+
};
1419
xhr.onerror = () => reject();
1520

1621
xhr.send( body );

0 commit comments

Comments
 (0)