0

Login.js This is login page designed in Reactjs and requirement is goto next page after next page after successful authentication, But database is created using postgreSQL and table name is 'user' which stores username and password. And development requirements are:

  • frontend :reactjs
  • backend : restify(nodejs)
  • Database : postgreSQL So I want to know how i can connect postgreSQL table to this login page and how authenticate user?
    class Login extends Component {
        render() {
            return (
                <div>
                <div >
                <div >
                    <h1 >Login</h1>
                <div >
                    <input type="text" placeholder="Username"/>
                </div>
                <div>
                    <input type="password" placeholder="Password"/>
                </div>
                    <button type="submit">Log in</button>
              
                </div>
                </div>
                </div>
            )
        }
    }
    
    export default Login

1 Answer 1

1

It seems you are a beginner with the concepts,

You must try to check some tutorials and then start.

Coming back to your question I will try to answer as simple I can,

  1. Frontend (react in your example) will need to consume some API (login API of your backend).
  2. Your backend will be created in nodejs using restify (As per your example), this piece of code will integrate with a database which is postgress (as per your example).
  3. this backend will receive the request body from say Frontend and validate in the database and give respectively user found or not found response.
  4. If the user found a response your frontend will route to the next page or in case not found frontend will show error message respectively.

Hope you got the idea,

Caveat:- there will so many concepts like hashing, token, cookie, local storage, etc that will come in the journey.

Sign up to request clarification or add additional context in comments.

5 Comments

ok You explain me flow of my problem and its solution, I request you to suggest me some resources to learn
on youtube just search login with MERN stack you will get many free tutorials
I am sorry, I was not very clear with the comment, in MERN you will get MongoDB and Express JS, but what I meant was you will understand basics and then can change express with restify and MongoDB with Postgress
1. can u tell me, whats the difference between nodejs and restify? 2. how we can create table in postgresql in restify?
Nodejs is runtime for javascript, restify is library or framework to create APIs, I suggest learn nodejs, than express, than restify.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.