React 里调用axios

前端之家收集整理的这篇文章主要介绍了React 里调用axios前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


React 里调用axios

this.confirmPasswordModal = () => {
      const { passwordParams,passwordValidation,passwordChanging } = this.state;
      console.log('passwordParams',passwordParams);
      const { value:{oldPassword,newPassword} } = passwordParams;
      if (passwordValidation) {
        axios.put(USER_URL.changePassword,{oldPassword,newPassword})//请求发送数据
          .then(function (response) {//请求成功
            UserActions.changePasswordSuccess(response);
            var Box=document.getElementById("layerteacher");
            Box.style.display="block";
            setTimeout(function(){Box.style.display='none'},2000);

          }.bind(this))
          .catch(function (error) {//请求失败!
            UserActions.changePasswordError(error);
            var hide=document.getElementById("layerHide");
            hide.style.display="block";
            setTimeout(function(){hide.style.display='none'},2000);
          }.bind(this));
      }
    }
原文链接:https://www.f2er.com/react/302812.html

猜你在找的React相关文章