我正在尝试使用trapi的身份验证文档中的忘记密码功能。尝试向api发送忘记密码的请求时,返回401错误。我正在使用vue js作为前端框架。
<template>
<form @submit.prevent="onForgetPassword">
<label for="name">your email</label>
<input type="email" class="from-input" placeholder="Enter Your Email..." v-model="email"/>
<button type="submit" class="form-btn">reset password</button>
</form>
</template>
data() {
return {
email: ""
};
},
methods: {
onForgetPassword() {
axios
.post("http://localhost:1337/auth/forgot-password", {
email: this.email
})
.then(response => {
// Handle success.
console.log("Your user received an email");
})
.catch(error => {
// Handle error.
console.log("An error occurred:", error);
});
}
}