5

I am using loopback framework(Node.js) with angular js(front end) and postgresql (DB)for my application,In my application i used third party login "passport-google-oauth".

After the google auth, call back url return the response as below mentioned code.

EX: http://localhost:3000/gauthServer

File: routes.js

app.get('/gauthServer', function(req, res) {
        console.log(req.cookies.currentUserEmail);
        console.log(req.cookies.currentUsername);
        console.log(req.cookies.currentUserId);
        console.log(req.cookies.accessToken);
        //res.redirect("/");
    });

In the above code it return the response correctly what i printed in console.log().

Expecting Result : I want the above results to store in postgresql DB.

siva
  • 593
  • 3
  • 8
  • 19

1 Answers1

1

The answer is simple but too broad.

Basically what you have to do is:

  1. Create datasource with slc loopback:datasource command and select postgresql connector
  2. Do npm i loopback-connector-postgresql --save
  3. Use slc loopback:model command to create model that will contain properties mentioned above and connect it to database. Again wizard will help you to do so.
  4. Save your data to database using create method on your model

You may also find this answer useful.

Community
  • 1
  • 1
A.Z.
  • 1,638
  • 2
  • 18
  • 27