AngularJS: problem with calling http chain and NodeJS: problem using variable in multiple HTTP calls

I have a call call and a mail call in my node.js file, both of which use the same variable that I initialized with an empty string outside of these calls. In the post call, I set the variable, while in the get call I return the value of the variable to my client angularjs that are requesting the value. In my angularjs file, I first make a post call and then a get call, which means the value must be set and must be available when the get call is issued and returned. That's what I'm doing:

NodeJS

var myUrl= "";
app.post('/post', function(req, res){
   myUrl = res.url;
}); 

app.get('/get, function(req, res){
    res.json({result: myUrl});
});

AngularJS:

var promise = $http.post('/post')
        .then(function(response){

            return $http.get('/get');

        }).then(function(response){
            console.log(response.data.result);
        });

AngularJS, . , , , get , url , , get call . get , .. ..

, , , , get , ( get , )? NodeJS, !

+4
1

angular , . , .

:

var myUrl= "";
app.post('/post', function(req, res){
   //not res.url
   myUrl = req.url;
   //Your missed this!
   res.status(204).end();
}); 

app.get('/get, function(req, res){
    res.json({result: myUrl});
});

:

res.status(204).end(); res.send({}) res.json({}) /post URL-, , , , . , /get, URL-.

, middleware, next.

, - . res.status(204).end();, : There is no content to serve

, !

+3

All Articles