Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 5x 5x 5x 5x 1x 1x 5x 4x 4x 4x 1x 1x 1x 1x 1x | /** * Delete a resource * * @param {ResourcefulApi} api * @param {String} moduleName */ import { NotFoundApiError } from '../../errors/ApiError' export function deleteAction (api, moduleName) { return new Proxy(() => {}, { apply (target, thisArg, [vuexFns, query]) { vuexFns.commit('startLoading') let id = query.id if (id === undefined) { id = query query = { id } } return api[moduleName].delete(query).then(response => { vuexFns.commit('remove', id) vuexFns.commit('endLoading') return response }).catch(error => { Iif (!(error instanceof NotFoundApiError)) { return error } vuexFns.commit('remove', id) vuexFns.commit('endLoading') Iif (error.hasErrorInfo()) { // TODO: what to do with the error info? /** * It would probably be nice to pass it on to the users, * however, as a 404 is a valid response on DELETE, it may * be weird to require users to write their own `.catch()` * blocks just to handle the meta data. Not quite sure how * to proceed here at the moment. */ } return null }) } }) } |