Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
fetch data from the API while redirecting in ReactJS

Given is an application with which you can manage users. Click on a button to be redirected to the UserManagement page:

<Router>
                                      
  <Button><Link to="/user" id="OpenUserManagementButton">
 <i className="fa fg"></i>UserManagement</Link></Button>
        <Routes>
          
          <Route path="/user" element={<UserManagementPage />} />

        </Routes>
      </Router>

At the same time the click should load all available users from the backend.

For this, the following function is now available in the ManagementAction.js.

export function showallUser() {

    console.log("Show all Users")
    return dispatch => {
        dispatch(getShowUserManagementAction());
        showUser().then(userSession => {
            const action = getShowUserManagementActionSuccess(userSession);
            dispatch(action);
        }, error => { dispatch(getShowUserManagementErrorAction(error)); }).catch(error => { dispatch(getShowUserManagementErrorAction(error)); })
    }


}

function showUser() {
   const token = localStorage.getItem("token")
    const requestOptions = {
        method: 'GET',
        headers: { 'Authorization': `Bearer ${token}` },

    };


    return fetch('https://localhost:443/user/', requestOptions)
        .then(handleResponse)
        .then(userSession => {
            return userSession;
        });


}

The UserManagementPage looks like this:

class UserManagementPage extends Component {

    constructor(props) {
        super(props);
        this.state = { userList: [] }

    }
render() {



        return (


            <div className="page-content" id="UserManagementPage" style={{ background: 'white' }}>

                <UserList />
                {this.state.users}




            </div>


        )
    }
}

export default UserManagementPage

question: How can I use the showUser and showallUser functions to show me all users ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda