Tuesday 23 May 2017

Nodejs cannot Read and Write simultaneously

I am currently trying to develop a NodeJS application, which contains 3 main Routes:

app.get('/1',(req, res) => {
res.sendFile(path.join(__dirname, './index.html'))
});

app.post('/1',(req, res) => {
model.sharetime(req.body.zeit);
});

and

app.get('/receive', (req, res) => {
res.json(model.receivetime());
});

The post Route /1 will be called once ever second, which receives a value that is put into an array.

The problem that I encounter is, each time I want to call the route /receive while the /1 get route is open, there is no response whatsoever,

after I restart the server, suddenly I get the response that I requested.

Which basically means, I cant have the route /1 which opens my index file open which I need for the application to post results back to the server and simultaneously receive the updated values via the route /receive.

Please help :)



via sharkschrek

No comments:

Post a Comment