Missing render HTML element for login requests from client to server

17 views Asked by At

I am writing a function for sending login requests from client to server which supports different roles/permissions upon each type of user and render the corresponding html elements.

decodeToken(token)
    .then(({userID, userRole}) => {
        if(userRole == 'admin'){
            console.log('admin')
            res.render('index', { link: 'http://127.0.0.1/makeAdmin.html', 
                linkText: 'Account permission A granted' });
        }
        else if(userRole == 'doctor'){
            res.render('index', {link: 'http://127.0.0.1/storein4.html', 
                linkText: 'Patients List'})
            console.log('doctor')
        }
        else if(userRole == 'nurse'){
            console.log('nurse')
            res.render('index', {link: 'http://127.0.0.1/storein4.html', 
                linkText: 'Patients List'})
        }
        else {
           console.log('patient')
        }
    }
)

The problem is: When I tried to log in, it sent the request and the corresponding render worked correctly. But when I switched to a subpage from that page, the render lost its previous state.

When I reloaded the page, I sent another request to the server. The request was correct, but the render failed to load the exact element that I coded.

0

There are 0 answers