Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,7 +45,7 @@ export class Basic extends Transport {
xhr.open(
request.method,
url,
true /* async */,
asynchronous,
this.credentials.username,
this.credentials.password
);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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({
Expand Down