diff --git a/lib/transport.js b/lib/transport.js index 03104de3..144ba730 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -35,6 +35,7 @@ export class Basic extends Transport { send(request, url, options) { return co(function *() { let sandbox = options && options.sandbox; + let asynchronous = options && options.async !== undefined ? options.async : true; let transformRequest = request.transformRequest; let transformResponse = request.transformResponse; let onerror = request.onerror; @@ -44,7 +45,7 @@ export class Basic extends Transport { xhr.open( request.method, url, - true /* async */, + asynchronous, this.credentials.username, this.credentials.password ); @@ -76,6 +77,7 @@ export class OAuth2 extends Transport { send(request, url, options={}) { return co(function *() { let sandbox = options.sandbox; + let asynchronous = options && options.async !== undefined ? options.async : true; let transformRequest = request.transformRequest; let transformResponse = request.transformResponse; let onerror = request.onerror; @@ -87,7 +89,7 @@ export class OAuth2 extends Transport { let token = yield access(this.credentials, options); xhr = new XMLHttpRequest(); if (sandbox) sandbox.add(xhr); - xhr.open(request.method, url, true /* async */); + xhr.open(request.method, url, asynchronous); xhr.setRequestHeader('Authorization', `Bearer ${token}`); if (transformRequest) transformRequest(xhr); yield xhr.send(request.requestData); @@ -132,9 +134,10 @@ function isExpired(credentials) { let getAccessToken = co.wrap(function *(credentials, options) { let sandbox = options.sandbox; + let asynchronous = options && options.async !== undefined ? options.async : true; let xhr = new XMLHttpRequest(); if (sandbox) sandbox.add(xhr); - xhr.open('POST', credentials.tokenUrl, true /* async */); + xhr.open('POST', credentials.tokenUrl, asynchronous); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); let data = querystring.stringify({