diff --git a/dist/vue-resource.common.js b/dist/vue-resource.common.js index 4ef216cd..4ca5f115 100644 --- a/dist/vue-resource.common.js +++ b/dist/vue-resource.common.js @@ -1423,7 +1423,7 @@ Http.headers = { Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors}; Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; -['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) { +['get', 'delete', 'head', 'jsonp', 'options'].forEach(function (method$$1) { Http[method$$1] = function (url, options$$1) { return this(assign(options$$1 || {}, {url: url, method: method$$1})); @@ -1509,7 +1509,8 @@ Resource.actions = { query: {method: 'GET'}, update: {method: 'PUT'}, remove: {method: 'DELETE'}, - delete: {method: 'DELETE'} + delete: {method: 'DELETE'}, + options: {method: 'OPTIONS'} }; diff --git a/dist/vue-resource.es2015.js b/dist/vue-resource.es2015.js index 963ad5e9..565b4260 100644 --- a/dist/vue-resource.es2015.js +++ b/dist/vue-resource.es2015.js @@ -1421,7 +1421,7 @@ Http.headers = { Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors}; Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; -['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) { +['get', 'delete', 'head', 'jsonp', 'options'].forEach(function (method$$1) { Http[method$$1] = function (url, options$$1) { return this(assign(options$$1 || {}, {url: url, method: method$$1})); @@ -1507,7 +1507,8 @@ Resource.actions = { query: {method: 'GET'}, update: {method: 'PUT'}, remove: {method: 'DELETE'}, - delete: {method: 'DELETE'} + delete: {method: 'DELETE'}, + options: {method: 'OPTIONS'} }; diff --git a/dist/vue-resource.js b/dist/vue-resource.js index c3ebb9ac..c0518053 100644 --- a/dist/vue-resource.js +++ b/dist/vue-resource.js @@ -1427,7 +1427,7 @@ Http.headers = { Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors}; Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; -['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) { +['get', 'delete', 'head', 'jsonp', 'options'].forEach(function (method$$1) { Http[method$$1] = function (url, options$$1) { return this(assign(options$$1 || {}, {url: url, method: method$$1})); @@ -1513,7 +1513,8 @@ Resource.actions = { query: {method: 'GET'}, update: {method: 'PUT'}, remove: {method: 'DELETE'}, - delete: {method: 'DELETE'} + delete: {method: 'DELETE'}, + options: {method: 'OPTIONS'} }; diff --git a/dist/vue-resource.min.js b/dist/vue-resource.min.js index 5d2e09bb..1b1956c2 100644 --- a/dist/vue-resource.min.js +++ b/dist/vue-resource.min.js @@ -4,4 +4,4 @@ * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueResource=e()}(this,function(){"use strict";function t(t){this.state=J,this.value=void 0,this.deferred=[];var e=this;try{t(function(t){e.resolve(t)},function(t){e.reject(t)})}catch(t){e.reject(t)}}function e(t,e){t instanceof Promise?this.promise=t:this.promise=new Promise(t.bind(e)),this.context=e}function n(t){"undefined"!=typeof console&&_&&console.warn("[VueResource warn]: "+t)}function o(t){"undefined"!=typeof console&&console.error(t)}function r(t,e){return F(t,e)}function i(t){return t?t.replace(/^\s*|\s*$/g,""):""}function u(t,e){return t&&void 0===e?t.replace(/\s+$/,""):t&&e?t.replace(new RegExp("["+e+"]+$"),""):t}function s(t){return t?t.toLowerCase():""}function a(t){return t?t.toUpperCase():""}function c(t){return"string"==typeof t}function f(t){return"function"==typeof t}function p(t){return null!==t&&"object"==typeof t}function h(t){return p(t)&&Object.getPrototypeOf(t)==Object.prototype}function d(t){return"undefined"!=typeof Blob&&t instanceof Blob}function l(t){return"undefined"!=typeof FormData&&t instanceof FormData}function m(t,n,o){var r=e.resolve(t);return arguments.length<2?r:r.then(n,o)}function y(t,e,n){return n=n||{},f(n)&&(n=n.call(e)),b(t.bind({$vm:e,$options:n}),t,{$options:n})}function v(t,e){var n,o;if(Q(t))for(n=0;n=200&&r<300,this.status=r||0,this.statusText=i||"",this.headers=new mt(o),this.body=t,c(t)?this.bodyText=t:d(t)&&(this.bodyBlob=t,L(t)&&(this.bodyText=H(t)))};yt.prototype.blob=function(){return m(this.bodyBlob)},yt.prototype.text=function(){return m(this.bodyText)},yt.prototype.json=function(){return m(this.text(),function(t){return JSON.parse(t)})},Object.defineProperty(yt.prototype,"data",{get:function(){return this.body},set:function(t){this.body=t}});var vt=function(t){this.body=null,this.params={},Y(this,t,{method:a(t.method||"GET")}),this.headers instanceof mt||(this.headers=new mt(this.headers))};vt.prototype.getUrl=function(){return U(this)},vt.prototype.getBody=function(){return this.body},vt.prototype.respondWith=function(t,e){return new yt(t,Y(e||{},{url:this.getUrl()}))};var bt={Accept:"application/json, text/plain, */*"},gt={"Content-Type":"application/json;charset=utf-8"};return B.options={},B.headers={put:gt,post:gt,patch:gt,delete:gt,common:bt,custom:{}},B.interceptor={before:ct,method:ft,jsonp:at,json:ut,form:it,header:pt,cors:rt},B.interceptors=["before","method","jsonp","json","form","header","cors"],["get","delete","head","jsonp"].forEach(function(t){B[t]=function(e,n){return this(Y(n||{},{url:e,method:t}))}}),["post","put","patch"].forEach(function(t){B[t]=function(e,n,o){return this(Y(o||{},{url:e,method:t,body:n}))}}),M.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},delete:{method:"DELETE"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(D),D}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueResource=e()}(this,function(){"use strict";function t(t){this.state=D,this.value=void 0,this.deferred=[];var e=this;try{t(function(t){e.resolve(t)},function(t){e.reject(t)})}catch(t){e.reject(t)}}function e(t,e){t instanceof Promise?this.promise=t:this.promise=new Promise(t.bind(e)),this.context=e}function n(t){"undefined"!=typeof console&&V&&console.warn("[VueResource warn]: "+t)}function o(t){"undefined"!=typeof console&&console.error(t)}function r(t,e){return X(t,e)}function i(t){return t?t.replace(/^\s*|\s*$/g,""):""}function u(t,e){return t&&void 0===e?t.replace(/\s+$/,""):t&&e?t.replace(new RegExp("["+e+"]+$"),""):t}function s(t){return t?t.toLowerCase():""}function a(t){return t?t.toUpperCase():""}function c(t){return"string"==typeof t}function f(t){return"function"==typeof t}function p(t){return null!==t&&"object"==typeof t}function h(t){return p(t)&&Object.getPrototypeOf(t)==Object.prototype}function d(t){return"undefined"!=typeof Blob&&t instanceof Blob}function l(t){return"undefined"!=typeof FormData&&t instanceof FormData}function m(t,n,o){var r=e.resolve(t);return arguments.length<2?r:r.then(n,o)}function y(t,e,n){return n=n||{},f(n)&&(n=n.call(e)),b(t.bind({$vm:e,$options:n}),t,{$options:n})}function v(t,e){var n,o;if(K(t))for(n=0;n=200&&r<300,this.status=r||0,this.statusText=i||"",this.headers=new rt(o),this.body=t,c(t)?this.bodyText=t:d(t)&&(this.bodyBlob=t,H(t)&&(this.bodyText=q(t)))};it.prototype.blob=function(){return m(this.bodyBlob)},it.prototype.text=function(){return m(this.bodyText)},it.prototype.json=function(){return m(this.text(),function(t){return JSON.parse(t)})},Object.defineProperty(it.prototype,"data",{get:function(){return this.body},set:function(t){this.body=t}});var ut=function(t){this.body=null,this.params={},Q(this,t,{method:a(t.method||"GET")}),this.headers instanceof rt||(this.headers=new rt(this.headers))};ut.prototype.getUrl=function(){return $(this)},ut.prototype.getBody=function(){return this.body},ut.prototype.respondWith=function(t,e){return new it(t,Q(e||{},{url:this.getUrl()}))};var st={Accept:"application/json, text/plain, */*"},at={"Content-Type":"application/json;charset=utf-8"};return L.options={},L.headers={put:at,post:at,patch:at,delete:at,common:st,custom:{}},L.interceptor={before:function(t,e){f(t.before)&&t.before.call(this,t),e()},method:function(t,e){t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers.set("X-HTTP-Method-Override",t.method),t.method="POST"),e()},jsonp:function(t,e){"JSONP"==t.method&&(t.client=tt),e()},json:function(t,e){var n=t.headers.get("Content-Type")||"";p(t.body)&&0===n.indexOf("application/json")&&(t.body=JSON.stringify(t.body)),e(function(t){return t.bodyText?m(t.text(),function(e){if(0===(n=t.headers.get("Content-Type")||"").indexOf("application/json")||A(e))try{t.body=JSON.parse(e)}catch(e){t.body=null}else t.body=e;return t}):t})},form:function(t,e){l(t.body)?t.headers.delete("Content-Type"):p(t.body)&&t.emulateJSON&&(t.body=$.params(t.body),t.headers.set("Content-Type","application/x-www-form-urlencoded")),e()},header:function(t,e){v(Q({},L.headers.common,t.crossOrigin?{}:L.headers.custom,L.headers[s(t.method)]),function(e,n){t.headers.has(n)||t.headers.set(n,e)}),e()},cors:function(t,e){if(_){var n=$.parse(location.href),o=$.parse(t.getUrl());o.protocol===n.protocol&&o.host===n.host||(t.crossOrigin=!0,t.emulateHTTP=!1,Z||(t.client=Y))}e()}},L.interceptors=["before","method","jsonp","json","form","header","cors"],["get","delete","head","jsonp","options"].forEach(function(t){L[t]=function(e,n){return this(Q(n||{},{url:e,method:t}))}}),["post","put","patch"].forEach(function(t){L[t]=function(e,n,o){return this(Q(o||{},{url:e,method:t,body:n}))}}),B.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},delete:{method:"DELETE"},options:{method:"OPTIONS"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(M),M}); \ No newline at end of file diff --git a/src/http/index.js b/src/http/index.js index d1bda3ca..bfd99cee 100644 --- a/src/http/index.js +++ b/src/http/index.js @@ -63,7 +63,7 @@ Http.headers = { Http.interceptor = {before, method, jsonp, json, form, header, cors}; Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; -['get', 'delete', 'head', 'jsonp'].forEach(method => { +['get', 'delete', 'head', 'jsonp', 'options'].forEach(method => { Http[method] = function (url, options) { return this(assign(options || {}, {url, method})); diff --git a/src/resource.js b/src/resource.js index 6cabd1b7..690db6ca 100644 --- a/src/resource.js +++ b/src/resource.js @@ -71,6 +71,7 @@ Resource.actions = { query: {method: 'GET'}, update: {method: 'PUT'}, remove: {method: 'DELETE'}, - delete: {method: 'DELETE'} + delete: {method: 'DELETE'}, + options: {method: 'OPTIONS'} };