mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 04:08:34 +03:00
39967b02da
Closes #2849 -wire up delete post action in ember admin -refactor ember modal dialog -override RESTAdapter.deleteRecord to workaround Ember expecting an empty response body on DELETEs
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import ghostPaths from 'ghost/utils/ghost-paths';
|
|
|
|
// export default DS.FixtureAdapter.extend({});
|
|
|
|
export default DS.RESTAdapter.extend({
|
|
host: window.location.origin,
|
|
namespace: ghostPaths().apiRoot.slice(1),
|
|
headers: {
|
|
'X-CSRF-Token': $('meta[name="csrf-param"]').attr('content')
|
|
},
|
|
|
|
buildURL: function (type, id) {
|
|
// Ensure trailing slashes
|
|
var url = this._super(type, id);
|
|
|
|
if (url.slice(-1) !== '/') {
|
|
url += '/';
|
|
}
|
|
|
|
return url;
|
|
},
|
|
|
|
// Override deleteRecord to disregard the response body on 2xx responses.
|
|
// This is currently needed because the API is returning status 200 along
|
|
// with the JSON object for the deleted entity and Ember expects an empty
|
|
// response body for successful DELETEs.
|
|
// Non-2xx (failure) responses will still work correctly as Ember will turn
|
|
// them into rejected promises.
|
|
deleteRecord: function () {
|
|
var response = this._super.apply(this, arguments);
|
|
|
|
return response.then(function () {
|
|
return null;
|
|
});
|
|
}
|
|
}); |