Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I am new to mean stack , in fact working on my very first project , i want to remember the request from the specific browser , which i have done using cookies . After that i want to send the history data from the server specific to every request which i am not able to do , as i couldnt find a suitable way . i tried using sessionstorage in angular js but that doesnt pull the session data i kept in node js ) Please let me know how is make it .

Node js: when i have set session var titles here in node js

var chkck = function(req,res,next){
    console.log("inside cookie callback .. ");

req.session.titles = req.session.titles || [];
//titles.push(req.params.)
 req.session.titles.push("22");
    res.sendFile("F:/customer/public/index.html");
}


app.use(chkck);


app.get('/',function(req,res){
res.sendFile("F:/customer/public/index.html");});

angular js: but in angular , i am not able to retrieve the titles from sessionstorage .

var nameapp=angular.module('name-App',["ngRoute",'ngCookies','ngStorage']);
    nameapp.controller('NameCtrl',
        function($scope,$http,$window, $cookieStore,$sessionStorage ){
            $scope.arr=[];
         $scope.finddet=function(){


            console.log("sessionstorage.titles"+ $sessionStorage.titles);
}});

this gives undefined

share|improve this question

In your Nodejs code: convert your response to JSON

res.send(JSON.stringify(data));

Sample answer

AnguarJs:

In your controller file,

$http.get(/your_url).then(function(response){

   // You will get the above response here  in response.data

  })
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.