issue with axios unhandled promise internet explor

2019-06-14 09:44发布

问题:

I am using React with axios and experiencing difficulties with IE11+ and seeing the following error:

Unhandled promise rejection TypeError: Unable to get property 'getHostNode' of undefined or null reference.

Everything works fine in Chrome, Safari and Firefox.

export const getData = () => {
    return axios.get('data.json');
};

I then use this above call in a redux action

export const getAllData = () => {
    return dispatch => {
        api.getData().then(resp => {
            dispatch(getDataSuccess(resp.data));
            resolve(resp);
        }).catch(err => {
            dispatch(getDataError(err));
            reject(err);
        });
    };
};

Finally I call this action in my react component

......

componentWillMount() {
   this.props.getAllData();
}

.....