失败的获取错误通知

时间:2017-08-07 09:58:07

标签: javascript ajax reactjs

我想在出现内部错误时显示错误通知但是这不起作用我希望你能帮助我。

   export const deleter = (url, params) => {
        return(dispatch, getState, api) => {
                api += 'api/';
            return fetch(`${api}${url}`, {
                method: 'DELETE',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(params)
            })
            .then(response => response.json())
            .then(result => dispatch(departmentResult(result, types.DELETER)))
            .catch(err => {
                    const errStatus = err.response ? err.response.status : 500;
                    if (errStatus == 500 || errStatus == 404){
                      return (NotificationManager.error('Sorry but this has already been used', 'ERROR! '));
                    } else {
                       return (NotificationManager.error('Sorry but this has already been used', 'ERROR! '));
                    }
           });
        }
    }

0 个答案:

没有答案