Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!