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