diff --git a/src/Requestor.js b/src/Requestor.js index 1b223b8f..59e1de9b 100644 --- a/src/Requestor.js +++ b/src/Requestor.js @@ -17,15 +17,24 @@ function fetchJSON(endpoint, callback) { xhr.open('GET', endpoint); xhr.send(); + + return xhr; } +var flagSettingsRequest; + function Requestor(baseUrl, environment) { var requestor = {}; requestor.fetchFlagSettings = function(user, hash, callback) { var data = utils.base64URLEncode(JSON.stringify(user)); var endpoint = [baseUrl, '/sdk/eval/', environment, '/users/', data, hash ? '?h=' + hash : ''].join(''); - fetchJSON(endpoint, callback); + + if (flagSettingsRequest) { + flagSettingsRequest.abort(); + } + + flagSettingsRequest = fetchJSON(endpoint, callback); }; requestor.fetchGoals = function(callback) {