Javascript laravel(vuejs和vuex)参数太多,无法在callResetPassword中运行

Javascript laravel(vuejs和vuex)参数太多,无法在callResetPassword中运行,javascript,php,laravel,vue.js,Javascript,Php,Laravel,Vue.js,我正在使用laravel(使用vue和vuex)在我的web应用程序上创建忘记密码。我找到了一个很好的教程(),但遗憾的是,由于错误,它无法重置密码 消息:函数App\Http\Controller\API\AuthController::callResetPassword()的参数太少,已传递0 正好有两个 我不知道怎么修理它 代码 web.php routes.js AuthController.php(处理重置密码) auth.js(Vuex) ResetPasswordForm.vue

我正在使用laravel(使用vue和vuex)在我的web应用程序上创建忘记密码。我找到了一个很好的教程(),但遗憾的是,由于错误,它无法重置密码

消息:函数App\Http\Controller\API\AuthController::callResetPassword()的参数太少,已传递0 正好有两个

我不知道怎么修理它


代码 web.php

routes.js

AuthController.php(处理重置密码)

auth.js(Vuex)

ResetPasswordForm.vue

methods: {
    ...mapActions(["resetPassword"]),
    reset() {
       this.resetPassword({
        token: this.$route.params.token, 
        email: this.email,
        password: this.password
      })
        .then(response => {
          toast.fire({
            type: "success",
            title: "Password reset successfully."
          });
          this.$router.push({ name: "login" });
        })
        .catch(error => {
          swal.fire({
            type: "error",
            text: error.response.data.message,
            showConfirmButton: false,
            timer: 3000
          });
        });
    }
  }
}

您需要在general中提供javascript调用或api调用,因此在脚本的某个地方调用此方法
callResetPassword
,而不传递任何参数

在这种情况下,您需要使用
$user
$password
调用方法
callResetPassword($user,$password)

你应该有这样的东西:

    requestResetPassword() {
        this.$http.post("/auth/reset/password/", {
            token: this.$route.params.token,
            email: this.email,
            password: this.password,
            password_confirmation: this.password_confirmation
        .then(result => {
            this.response = result.data;
            console.log(result.data);
        })
        .catch(error => {
            console.error(error);
        });

我们已经知道这与您的Vue应用程序无关。API
callResetPassword
在您的某个地方被调用,没有任何参数。查看该文件,并尝试跟踪此方法的调用位置。如果找不到,请用API的一些代码替换答案中的vue代码。@ThomasVanderVeen那么问题出在控制器上?我浏览了您提供的教程。Axios post请求通过参数email、password和reset token向该函数发出。因此,请确保您确实将它们发送到了控制器。@DinoNumić如何纠正错误?@Peejong我假设您实现了axios部分,因为您得到了错误。您必须对其进行调试,以找出其无法正确发送参数的原因。您可以硬编码您的电子邮件和密码,以检查这是否会有所帮助。如果这样做有效,那么您就知道Vue没有从输入中获取值。使用您的axios实现更新问题。我创建了一个类似于此的vuex操作,并在vue文件中导入,但错误仍然存在。@您能检查数据是否确实包含axios调用中的值吗them@Peejong没问题,先生,只要把这些记录下来,比如
token:data.token,email:data.email,密码:data.password
并检查它们是否实际包含值。明天我可以再帮你(10小时后,如果你愿意的话:))我怎么打?我可以把它放在哪里?
  public function callResetPassword($user, $password)
    {
        $user->password = Hash::make($password);
        $user->save();
        event(new PasswordReset($user));
    }
resetPassword(data){
    return new Promise((resolve,reject) => {
        axios.post('/reset/password',{
            token: data.token,
            email: data.email,
            password: data.password
        })
        .then(response =>{
            resolve(response)
        })
        .catch(error =>{
            reject(error)
        })
    })
}
methods: {
    ...mapActions(["resetPassword"]),
    reset() {
       this.resetPassword({
        token: this.$route.params.token, 
        email: this.email,
        password: this.password
      })
        .then(response => {
          toast.fire({
            type: "success",
            title: "Password reset successfully."
          });
          this.$router.push({ name: "login" });
        })
        .catch(error => {
          swal.fire({
            type: "error",
            text: error.response.data.message,
            showConfirmButton: false,
            timer: 3000
          });
        });
    }
  }
}
    requestResetPassword() {
        this.$http.post("/auth/reset/password/", {
            token: this.$route.params.token,
            email: this.email,
            password: this.password,
            password_confirmation: this.password_confirmation
        .then(result => {
            this.response = result.data;
            console.log(result.data);
        })
        .catch(error => {
            console.error(error);
        });