Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from ember-cli/remove-type-from-request
Browse files Browse the repository at this point in the history
Remove type from request params.
  • Loading branch information
taras committed Sep 30, 2015
2 parents c1063a4 + 7a20f83 commit 7720f67
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions addon/services/ajax.js
Expand Up @@ -9,6 +9,7 @@ import {
import parseResponseHeaders from '../utils/parse-response-headers';

const {
deprecate,
get
} = Ember;

Expand Down Expand Up @@ -73,8 +74,26 @@ const {
**/
export default Ember.Service.extend({

request(url, type, options) {
const hash = this.options(url, type, options);
request(url, options) {
var opts;

if (arguments.length > 2 || typeof options === 'string') {
deprecate(
'ember-ajax/ajax#request calling request with `type` is deprecated and will be removed in ember-ajax@1.0.0. If you want to specify a type pass an object like {type: \'DELETE\'}',
false, { id: 'ember-ajax.service.request' }
);

if (arguments.length > 2) {
opts = arguments[2];
opts.type = options;
} else {
opts = { type: options };
}
} else {
opts = options;
}

const hash = this.options(url, opts);

return new Ember.RSVP.Promise((resolve, reject) => {

Expand Down Expand Up @@ -121,10 +140,10 @@ export default Ember.Service.extend({
@param {Object} options
@return {Object}
*/
options(url, type, options) {
options(url, options) {
var hash = options || {};
hash.url = url;
hash.type = type || 'GET';
hash.type = hash.type || 'GET';
hash.dataType = hash.dataType || 'json';
hash.context = this;

Expand Down

0 comments on commit 7720f67

Please sign in to comment.