I am working on functionality where the user can hit 'test.com/sso' with post request. After validating the request, how can I send return value to Angular js 1.X? I am using nodeJs as a backend.
Asked
Active
Viewed 70 times
1 Answers
0
Nodejs -server.js
const express = require('express');
const app = express();
var path = require('path');
var bodyParser =require('body-parse');
app.use(express.static(path.join(__dirname, '/angular')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/sso', function(req,res){
//Something...(your code)
.then(data =>{
return res.status(200).json(data + "RESPONSE FROM SERVER");
)}.catch(error=>{
res.send(error);
)}
)};
app.listen(3000, function(){
console.log("Server Listening On Port 3000"):
)};

Raju Sah
- 540
- 5
- 16
-
are we returning value in our application, if other 3rd party hitting our API? – Rohit Khadatkar May 29 '20 at 02:47
-
ya, to allow it only for specific domain use response.set('Access-Control-Allow-Origin', 'domain.com'); you can also use 'npm vhost' package and for securing the app use 'npm helmet'. – Raju Sah May 30 '20 at 03:37