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

Remove type from request params. #8

Merged
merged 1 commit into from Sep 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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\'}',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taras not sure about this message, but that's a raw outline

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message seems fine

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