Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
React js handle error from request api Laravel

Hello guys I have a problem to handle error from validation Laravel i have service class

import axios from "axios";
import { LogIn } from "react-feather";
import Alert from "../components/Alert";
import { API_BASE_URL  , BASE_URL} from "../config";

class UserService {

   async getUserInformation(id){
       try{
        const result = await axios.get(API_BASE_URL + '/getUserInformation' , { params: { id: id } })
        return result.data.users
       }catch(e){
        return false;
       }
   }

   async saveUserInfromation(user){
       try{
        const result = await axios.put(API_BASE_URL + '/update' , user )
        return result.data.users
       }catch(e){
       
        return e.response.data;
       }
   }
}

export default new UserService();

and this is my component I call the function from class service to edit user

import React, { Component } from "react";

class Clientedit extends Component {
  constructor(props) {
    super(props);
    this.state = {
      user : {},
      oldPassword: "",
      newPassword: "",
      isLoading : true,
      error : "",
    };
  }

  componentDidMount() {
  }

   handleSubmit = (e) =>{
    e.preventDefault();
    let user = this.state.user;
    try{
      const res = UserService.saveUserInfromation(user);
    
    }
    catch(e){
      
    }
  }
  }
}
export default withParams(Clientedit);

when I log error from service class I get it in my consol enter image description here

but when I log it from my component I get nothing , any solution please

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You must set password_confirmation parameter when updating your password

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda