src/utilities/helpers.js
/**
 * Generic Errors handling for Axios
 *
 * @param context
 * @param error
 */
Generic Errors handling for Axios
@param context
@param error
Generic Errors handling for Axios @param context @param error
function errors (context, error) {
  if(typeof error !== 'undefined'){
    if(typeof error.response === 'undefined') {
      SweetAlert({
        title: i18n.t('error'),
        message: i18n.t('serverNotResponding'),
        type:'error'
      })
    } else {
      if(error.response.status === 400) {
        SweetAlert({
          title: i18n.t('error'),
          message: error.response.data.message,
          type:'error'
        })
      } else if(error.response.status === 401) {
        SweetAlert({
          title: i18n.t('error'),
          message: i18n.t('sessionExpired'),
          type:'error'
        })
        setTimeout(() => {
          window.location.reload();
        }, 3000);
      } else if(error.response.status === 403) {
        SweetAlert({
          title: i18n.t('error'),
          message: i18n.t('credentialMatch'),
          type:'error'
        })
      } else if(error.response.status === 404) {
        SweetAlert({
          title: i18n.t('error'),
          message: error.response.data.message,
          type:'error'
        })
      } else if(error.response.status === 405) {
        SweetAlert({
          title: i18n.t('error'),
          message: i18n.t('wrongHttp'),
          type:'error'
        })
      } else if(error.response.status === 406) {
        SweetAlert({
          title: i18n.t('error'),
          message: error.response.data.message,
          type:'error'
        })
      } else if(error.response.status === 409) {
        SweetAlert({
          title: i18n.t('error'),
          message: error.response.data.message,
          type:'error'
        })
      } else if(error.response.status === 422) {
        let errors = error.response.data.messages;
        for (var key in errors) {
           var caseErrors = errors[key];
           for(var i in caseErrors) {
             SweetAlert({
               title: i18n.t('error'),
               message: caseErrors[i][0],
               type:'error'
             });
           }
        }
      } else if(error.response.status >= 500) {
        SweetAlert({
          title: i18n.t('error'),
          message: i18n.t('serverNotResponding'),
          type:'error'
        })
      }
    }
  }
}
function errors ( context , error ) { if ( typeof error !== 'undefined' ) { if ( typeof error . response === 'undefined' ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : i18n . t ( 'serverNotResponding' ) , type : 'error' } ) } else { if ( error . response . status === 400 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : error . response . data . message , type : 'error' } ) } else if ( error . response . status === 401 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : i18n . t ( 'sessionExpired' ) , type : 'error' } ) setTimeout ( ( ) => { window . location . reload ( ) ; } , 3000 ) ; } else if ( error . response . status === 403 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : i18n . t ( 'credentialMatch' ) , type : 'error' } ) } else if ( error . response . status === 404 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : error . response . data . message , type : 'error' } ) } else if ( error . response . status === 405 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : i18n . t ( 'wrongHttp' ) , type : 'error' } ) } else if ( error . response . status === 406 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : error . response . data . message , type : 'error' } ) } else if ( error . response . status === 409 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : error . response . data . message , type : 'error' } ) } else if ( error . response . status === 422 ) { let errors = error . response . data . messages ; for ( var key in errors ) { var caseErrors = errors [ key ] ; for ( var i in caseErrors ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : caseErrors [ i ] [ 0 ] , type : 'error' } ) ; } } } else if ( error . response . status >= 500 ) { SweetAlert ( { title : i18n . t ( 'error' ) , message : i18n . t ( 'serverNotResponding' ) , type : 'error' } ) } } } }
Generic Errors handling for Axios
 @param context
 @param error
Generic Errors handling for Axios @param context @param error
//toast.error('API Server is not responding or You are having some network issues'); //toast.error(error.response.data.message); //toast.error('Your session has been expired, please wait'); //toast.error('These credential do not match our records.'); //toast.error(error.response.data.message); //toast.error('You have used a wrong HTTP verb'); //toast.error(error.response.data.message); //toast.error(error.response.data.message, { autoClose: 10000 }); //toast.error(caseErrors[i][0], { autoClose: 10000 }); //toast.error("API Server is not responding or You are having some network issues", { autoClose: 8000 });