Skip to content

Commit ac3307b

Browse files
committed
Closes #161.
1 parent 0980600 commit ac3307b

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
###### Backwards compatible API changes
44
- #145 - Add "useClass" option to inject, find, findAll, create
5+
- #161 - Allow the http method of DSHttpAdapter methods to be configured
56
- #167 - Default params argument of bindAll to empty object
67

78
###### Backwards compatible bug fixes

dist/angular-data.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -1546,9 +1546,11 @@ function DSHttpAdapterProvider() {
15461546
*/
15471547
GET: function (url, config) {
15481548
config = config || {};
1549+
if (!('method' in config)) {
1550+
config.method = 'GET';
1551+
}
15491552
return this.HTTP(DSUtils.deepMixIn(config, {
1550-
url: url,
1551-
method: 'GET'
1553+
url: url
15521554
}));
15531555
},
15541556

@@ -1571,10 +1573,12 @@ function DSHttpAdapterProvider() {
15711573
*/
15721574
POST: function (url, attrs, config) {
15731575
config = config || {};
1576+
if (!('method' in config)) {
1577+
config.method = 'POST';
1578+
}
15741579
return this.HTTP(DSUtils.deepMixIn(config, {
15751580
url: url,
1576-
data: attrs,
1577-
method: 'POST'
1581+
data: attrs
15781582
}));
15791583
},
15801584

@@ -1597,10 +1601,12 @@ function DSHttpAdapterProvider() {
15971601
*/
15981602
PUT: function (url, attrs, config) {
15991603
config = config || {};
1604+
if (!('method' in config)) {
1605+
config.method = 'PUT';
1606+
}
16001607
return this.HTTP(DSUtils.deepMixIn(config, {
16011608
url: url,
1602-
data: attrs || {},
1603-
method: 'PUT'
1609+
data: attrs || {}
16041610
}));
16051611
},
16061612

@@ -1622,9 +1628,11 @@ function DSHttpAdapterProvider() {
16221628
*/
16231629
DEL: function (url, config) {
16241630
config = config || {};
1631+
if (!('method' in config)) {
1632+
config.method = 'DELETE';
1633+
}
16251634
return this.HTTP(DSUtils.deepMixIn(config, {
1626-
url: url,
1627-
method: 'DELETE'
1635+
url: url
16281636
}));
16291637
},
16301638

@@ -2651,7 +2659,6 @@ function _findAll(resourceName, params, options) {
26512659
return DS.$q.reject(err);
26522660
}
26532661
} else {
2654-
console.log(data);
26552662
DS.utils.forEach(data, function (item, i) {
26562663
data[i] = DS.createInstance(resourceName, item, options);
26572664
});

dist/angular-data.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/adapters/http.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ function DSHttpAdapterProvider() {
128128
*/
129129
GET: function (url, config) {
130130
config = config || {};
131+
if (!('method' in config)) {
132+
config.method = 'GET';
133+
}
131134
return this.HTTP(DSUtils.deepMixIn(config, {
132-
url: url,
133-
method: 'GET'
135+
url: url
134136
}));
135137
},
136138

@@ -153,10 +155,12 @@ function DSHttpAdapterProvider() {
153155
*/
154156
POST: function (url, attrs, config) {
155157
config = config || {};
158+
if (!('method' in config)) {
159+
config.method = 'POST';
160+
}
156161
return this.HTTP(DSUtils.deepMixIn(config, {
157162
url: url,
158-
data: attrs,
159-
method: 'POST'
163+
data: attrs
160164
}));
161165
},
162166

@@ -179,10 +183,12 @@ function DSHttpAdapterProvider() {
179183
*/
180184
PUT: function (url, attrs, config) {
181185
config = config || {};
186+
if (!('method' in config)) {
187+
config.method = 'PUT';
188+
}
182189
return this.HTTP(DSUtils.deepMixIn(config, {
183190
url: url,
184-
data: attrs || {},
185-
method: 'PUT'
191+
data: attrs || {}
186192
}));
187193
},
188194

@@ -204,9 +210,11 @@ function DSHttpAdapterProvider() {
204210
*/
205211
DEL: function (url, config) {
206212
config = config || {};
213+
if (!('method' in config)) {
214+
config.method = 'DELETE';
215+
}
207216
return this.HTTP(DSUtils.deepMixIn(config, {
208-
url: url,
209-
method: 'DELETE'
217+
url: url
210218
}));
211219
},
212220

src/datastore/async_methods/findAll.js

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function _findAll(resourceName, params, options) {
6262
return DS.$q.reject(err);
6363
}
6464
} else {
65-
console.log(data);
6665
DS.utils.forEach(data, function (item, i) {
6766
data[i] = DS.createInstance(resourceName, item, options);
6867
});

0 commit comments

Comments
 (0)