function deleteResource(url) {
  if (!url) {
    throw new Error('Cannot delete without url.');
  }

  const { key, actionName } = getActionAndKeyFromUrl('DELETE', url);
  return (dispatch) => {
    requestWithOutPayload('DELETE', url)
    .then((res) => {
      const action = createActionWithPayload(actionName, key, res);
      dispatch(action);
      // dispatch fetchResources with url ie. /subjects
      dispatch(fetchResources(url.slice(ZERO, url.lastIndexOf('/'))));
      dispatch(handleMessage('Successfully deleted ' + key + ': ' + res.id));
    })
    .catch((err) => {
      dispatch(handleError(err));
    });
  };
}
/**
 * Figures out resource: aspect or subject, based on the url.
 * Dipatches DELETE request to the supplied url
 * On returned response, dispatch success or error handlers.
 *
 * @param {String} url The relative url to the to-be-deleted resource:
 * ie. /subjects/73edeac7-de73-41f6-bf99-33d4a5557434
 */
Figures out resource: aspect or subject, based on the url.
Dipatches DELETE request to the supplied url
On returned response, dispatch success or error handlers.

@param {String} url The relative url to the to-be-deleted resource:
ie.
Figures out resource : aspect or subject based on the url . Dipatches DELETE request to the supplied url On returned response dispatch success or error handlers . @param { String } url The relative url to the to - be - deleted resource : ie .
function deleteResource(url) {
  if (!url) {
    throw new Error('Cannot delete without url.');
  }
  const { key, actionName } = getActionAndKeyFromUrl('DELETE', url);
  return (dispatch) => {
    requestWithOutPayload('DELETE', url)
    .then((res) => {
      const action = createActionWithPayload(actionName, key, res);
      dispatch(action);
      dispatch(fetchResources(url.slice(ZERO, url.lastIndexOf('/'))));
      dispatch(handleMessage('Successfully deleted ' + key + ': ' + res.id));
    })
    .catch((err) => {
      dispatch(handleError(err));
    });
  };
}
function deleteResource ( url ) { if ( ! url ) { throw new Error ( 'Cannot delete without url.' ) ; } const { key , actionName } = getActionAndKeyFromUrl ( 'DELETE' , url ) ; return ( dispatch ) => { requestWithOutPayload ( 'DELETE' , url ) . then ( ( res ) => { const action = createActionWithPayload ( actionName , key , res ) ; dispatch ( action ) ; dispatch ( fetchResources ( url . slice ( ZERO , url . lastIndexOf ( '/' ) ) ) ) ; dispatch ( handleMessage ( 'Successfully deleted ' + key + ': ' + res . id ) ) ; } ) . catch ( ( err ) => { dispatch ( handleError ( err ) ) ; } ) ; } ; }
Figures out resource: aspect or subject, based on the url.
Figures out resource : aspect or subject based on the url .
// dispatch fetchResources with url ie. /subjects