Skip to content

Commit 1e1a76a

Browse files
committed
Added Delete Method
1 parent b953541 commit 1e1a76a

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/actions/Delete.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1+
import Axios from '../orm/axios';
12
import Action from './Action'
3+
import Context from '../common/context'
24

35
export default class Delete extends Action {
4-
static call ({ state, dispatch }, params={}) {
5-
console.log(state, dispatch, params);
6+
/**
7+
* Call $delete method
8+
* @param {object} store
9+
* @param {object} params
10+
*/
11+
static async call ({ state, commit }, params = {}) {
12+
const context = Context.getInstance();
13+
const model = context.getModelFromState(state);
14+
const endpoint = Action.transformParams('$delete', model, params);
15+
const axios = new Axios(model.methodConf.http);
16+
const request = axios.delete(endpoint);
17+
18+
request
19+
.then(data => {
20+
model.delete({
21+
where: (params.params.id) ? params.params.id : data.id,
22+
})
23+
})
24+
25+
return request;
626
}
727
}

0 commit comments

Comments
 (0)