diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 4d45e89..70b880b 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,5 +1,9 @@ # Changelog +## 1.1.4 + +- Adds a message response when receiving a 429 HTTP error [#115](https://github.com/simperium/node-simperium/pull/115) + ## 1.1.3 - Fixes a sync issue by reverting the changes from PR #101 [#114](https://github.com/simperium/node-simperium/pull/114) diff --git a/package-lock.json b/package-lock.json index beb79a7..b516168 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "simperium", - "version": "1.1.3", + "version": "1.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 532fb2c..40f8654 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simperium", - "version": "1.1.3", + "version": "1.1.4", "description": "A simperium client for node.js", "main": "./lib/simperium/index.js", "browser": { diff --git a/src/simperium/http-request.browser.js b/src/simperium/http-request.browser.js index 46e567f..d950a0c 100644 --- a/src/simperium/http-request.browser.js +++ b/src/simperium/http-request.browser.js @@ -10,7 +10,12 @@ export default function( xhr.open( 'POST', url ); xhr.setRequestHeader( 'X-Simperium-API-Key', apiKey ); - xhr.onload = () => resolve( xhr.responseText ); + xhr.onload = () => { + if ( xhr.status === 429 && xhr.responseText === '' ) { + return resolve('too many requests'); + } + resolve(xhr.responseText); + }; xhr.onerror = () => reject(); xhr.send( body );