metal-ajax
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
@@ -68,2 +68,3 @@ 'use strict'; | ||
* @param {boolean=} opt_sync | ||
* @param {boolean=} opt_withCredentials | ||
* @return {Promise} Deferred ajax request. | ||
@@ -75,3 +76,3 @@ * @protected | ||
key: 'request', | ||
value: function request(url, method, body, opt_headers, opt_params, opt_timeout, opt_sync) { | ||
value: function request(url, method, body, opt_headers, opt_params, opt_timeout, opt_sync, opt_withCredentials) { | ||
var request = new XMLHttpRequest(); | ||
@@ -105,2 +106,6 @@ | ||
if (opt_withCredentials) { | ||
request.withCredentials = true; | ||
} | ||
if (opt_headers) { | ||
@@ -107,0 +112,0 @@ opt_headers.names().forEach(function (name) { |
{ | ||
"name": "metal-ajax", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"description": "Metal.js utility to perform Ajax requests", | ||
@@ -5,0 +5,0 @@ "license": "BSD", |
@@ -47,6 +47,7 @@ 'use strict'; | ||
* @param {boolean=} opt_sync | ||
* @param {boolean=} opt_withCredentials | ||
* @return {Promise} Deferred ajax request. | ||
* @protected | ||
*/ | ||
static request(url, method, body, opt_headers, opt_params, opt_timeout, opt_sync) { | ||
static request(url, method, body, opt_headers, opt_params, opt_timeout, opt_sync, opt_withCredentials) { | ||
var request = new XMLHttpRequest(); | ||
@@ -80,2 +81,6 @@ | ||
if (opt_withCredentials) { | ||
request.withCredentials = true; | ||
} | ||
if (opt_headers) { | ||
@@ -82,0 +87,0 @@ opt_headers.names().forEach(function(name) { |
@@ -65,2 +65,22 @@ 'use strict'; | ||
it('should send request with credentials', function(done) { | ||
let withCredentials = true; | ||
Ajax.request('/url', 'POST', null, null, null, null, false, withCredentials) | ||
.then(function(xhrResponse) { | ||
assert.ok(xhrResponse.withCredentials); | ||
done(); | ||
}); | ||
this.requests[0].respond(200); | ||
}); | ||
it('should send request without credentials', function(done) { | ||
let withCredentials = false; | ||
Ajax.request('/url', 'POST', null, null, null, null, false, withCredentials) | ||
.then(function(xhrResponse) { | ||
assert.notOk(xhrResponse.withCredentials); | ||
done(); | ||
}); | ||
this.requests[0].respond(200); | ||
}); | ||
it('should send request with different http method', function(done) { | ||
@@ -67,0 +87,0 @@ Ajax.request('/url', 'POST') |
14278
358