Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 1cc2d90

Browse files
committed
v0.1.11
1 parent 90605ea commit 1cc2d90

File tree

4 files changed

+21
-28
lines changed

4 files changed

+21
-28
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue-resource",
33
"main": "dist/vue-resource.js",
44
"description": "A web request service for Vue.js",
5-
"version": "0.1.10",
5+
"version": "0.1.11",
66
"homepage": "https://github.com/vuejs/vue-resource",
77
"license": "MIT",
88
"ignore": [

dist/vue-resource.js

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-resource v0.1.10
2+
* vue-resource v0.1.11
33
* https://github.com/vuejs/vue-resource
44
* Released under the MIT License.
55
*/
@@ -340,12 +340,13 @@ return /******/ (function(modules) { // webpackBootstrap
340340
var _ = __webpack_require__(2);
341341
var xhr = __webpack_require__(4);
342342
var jsonp = __webpack_require__(6);
343-
var jsonType = {'Content-Type': 'application/json;charset=utf-8'};
343+
var Promise = __webpack_require__(5);
344344

345345
module.exports = function (Vue) {
346346

347347
var Url = Vue.url;
348348
var originUrl = Url.parse(location.href);
349+
var jsonType = {'Content-Type': 'application/json;charset=utf-8'};
349350

350351
function Http(url, options) {
351352

@@ -396,22 +397,20 @@ return /******/ (function(modules) { // webpackBootstrap
396397
options.data = JSON.stringify(options.data);
397398
}
398399

399-
promise = (options.method.toLowerCase() == 'jsonp' ? jsonp : xhr).call(self, self.$url || Url, options);
400-
401-
promise.then(transformResponse, transformResponse);
400+
promise = (options.method.toLowerCase() == 'jsonp' ? jsonp : xhr).call(self, self.$url || Url, options).then(transformResponse, transformResponse);
402401

403402
promise.success = function (fn) {
404403

405404
promise.then(function (response) {
406405
fn.call(self, response.data, response.status, response);
407-
}, function () {});
406+
});
408407

409408
return promise;
410409
};
411410

412411
promise.error = function (fn) {
413412

414-
promise.catch(function (response) {
413+
promise.then(undefined, function (response) {
415414
fn.call(self, response.data, response.status, response);
416415
});
417416

@@ -448,6 +447,7 @@ return /******/ (function(modules) { // webpackBootstrap
448447
response.data = response.responseText;
449448
}
450449

450+
return response.ok ? response : Promise.reject(response);
451451
}
452452

453453
function crossOrigin(url) {
@@ -532,27 +532,17 @@ return /******/ (function(modules) { // webpackBootstrap
532532

533533
request.onreadystatechange = function () {
534534

535-
if (this.readyState === 4) {
535+
if (request.readyState === 4) {
536536

537-
if (this.status >= 200 && this.status < 300) {
538-
resolve(this);
539-
} else {
540-
reject(this);
541-
}
537+
request.ok = request.status >= 200 && request.status < 300;
538+
539+
(request.ok ? resolve : reject)(request);
542540
}
543541
};
544542

545543
request.send(options.data);
546544
});
547545

548-
_.extend(promise, {
549-
550-
abort: function () {
551-
request.abort();
552-
}
553-
554-
});
555-
556546
return promise;
557547
};
558548

@@ -786,7 +776,7 @@ return /******/ (function(modules) { // webpackBootstrap
786776

787777
module.exports = function (url, options) {
788778

789-
var callback = '_jsonp' + Math.random().toString(36).substr(2), script, body;
779+
var callback = '_jsonp' + Math.random().toString(36).substr(2), response = {}, script, body;
790780

791781
options.params[options.jsonp] = callback;
792782

@@ -814,9 +804,11 @@ return /******/ (function(modules) { // webpackBootstrap
814804
event.type = 'error';
815805
}
816806

817-
var text = body ? body : event.type, status = event.type === 'error' ? 404 : 200;
807+
response.ok = event.type !== 'error';
808+
response.status = response.ok ? 200 : 404;
809+
response.responseText = body ? body : event.type;
818810

819-
(status === 200 ? resolve : reject)({responseText: text, status: status});
811+
(response.ok ? resolve : reject)(response);
820812
};
821813

822814
script.onload = handler;
@@ -938,6 +930,7 @@ return /******/ (function(modules) { // webpackBootstrap
938930
get: {method: 'get'},
939931
save: {method: 'post'},
940932
query: {method: 'get'},
933+
update: {method: 'put'},
941934
remove: {method: 'delete'},
942935
delete: {method: 'delete'}
943936

0 commit comments

Comments
 (0)