# Node.js - Problem redirecting routine post method

**URL:** <https://discourse.nodered.org/t/node-js-problem-redirecting-routine-post-method/20586>\
**Category:** Share Your Nodes\
**Created:** [19 January 2020 18:29 UTC](https://discourse.nodered.org/t/node-js-problem-redirecting-routine-post-method/20586 "2020-01-19T18:29:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rngelmiguel](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@Rngelmiguel](https://discourse.nodered.org/u/Rngelmiguel)\
**Post date:** [19 January 2020 18:29 UTC](https://discourse.nodered.org/t/node-js-problem-redirecting-routine-post-method/20586/1 "2020-01-19T18:29:09Z")

</div>

Hi everyone

I write here for who can help me, since I'm new to NodeJS, I'm trying to do something simple, but in the end it doesn't work for me.

I want from the frontend, to make a request to the backend, through the ajax post method. When executing it, from the frontend send a JSON object to the backend and then from the backend it must redirect to another page to the frontend (the latter is what I could not achieve)

Example of what I try

**Frontend**  
var objAgente = {  
"FIRSTNAME": "PEDRO",  
"LASTNAME": "PEREZ",  
"NRORUT": "123456789",  
"NROAGENT": "3",  
"HRCONNECT": "12:12:12"  
};

$.ajax({  
type: 'POST',  
url: '/LoginAgente',  
data: JSON.stringify({ "objectData": objAgente}),  
success: function(data) {console.log('todo OK')},  
contentType: "application/json",  
dataType: 'json'  
});

**Backend**  
const express = require("express");  
const router = express.Router();

router.use(express.json()) // for parsing application/json

router.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

router.get('/', (req, res)=\>{

res.render('loading.html', { title: 'Iniciando Sistema'});

});

router.get('/Inicio', (req,res)=\>{

res.render('confInitial.html', { title: 'Inicio de Sistema'});

});

router.get('/Agente', (req,res)=\>{

res.render('PanelAgente/Agente.html', { title: 'Equipo solo Agente'});

});

router.post('/LoginAgente', function (req, res) {  
var newUser = req.body;  
console.log(newUser);  
res.redirect('/Agente');

});

module.exports = router;

When I execute the sending of the JSON object to the backend, the data arrives since I can print it by console, but the res.redirect is not fulfilled;

It does not return an error, but it does not redirect me to where I want.

Thank you very much to those who can give me an idea of ​​what happens

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 January 2020 19:14 UTC](https://discourse.nodered.org/t/node-js-problem-redirecting-routine-post-method/20586/2 "2020-01-19T19:14:07Z")

</div>

Hi @Rngelmiguel

This isn't a general node.js support forum - it's for Node-RED.

You may want to post your question to Stack Overflow where I'm sure there will be plenty of node.js developers who can help.
