This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/adapters/post.js
Jarek Radosz 67b34600d5
DEV: Use type instead of method in ajax calls (#8974)
Even though `type` is an alias for `method`, we have custom logic in `/discourse/lib/ajax` that checks only `type`, and ~200 other ajax calls in the codebase already use `type` param.
2020-03-26 21:00:10 +01:00

23 lines
652 B
JavaScript

import { ajax } from "discourse/lib/ajax";
import RestAdapter from "discourse/adapters/rest";
import { Result } from "discourse/adapters/rest";
import { underscore } from "@ember/string";
export default RestAdapter.extend({
find(store, type, findArgs) {
return this._super(store, type, findArgs).then(function(result) {
return { post: result };
});
},
createRecord(store, type, args) {
const typeField = underscore(type);
args.nested_post = true;
return ajax(this.pathFor(store, type), { type: "POST", data: args }).then(
function(json) {
return new Result(json[typeField], json);
}
);
}
});