Tuesday, 8 October 2019

Output of different userid gets mixed when requesting same api through angular in node js

I am facing this strange situation

I have one route in node js something like

route.post("/api",async(req,res)=>{
let userid=req.body.userid;
// requesting data from the db for particular userid
res.json({data:data})
})

Now When I requesting this api with setInterval from my angular app

export myClass{
data:any;
    GetData()
    {
    this.http.post("/api",{userid:userid}).subscribe(result=>{
     this.data=result

});



    }
}

Now when ,I am opening the app on different browsers ,I am requesting data for two different userids ,and in the result I am getting data of both the userids. There is no fancy in my code . I am unable to identify that this issue is related to angular or Node .Or Am I doing something wrong ? (which I don't think because its just the simple code) .Any suggestions Please



from Output of different userid gets mixed when requesting same api through angular in node js

No comments:

Post a Comment