POST call remains pending
See original GitHub issueDescribe the bug
The call POST call remains pending
To Reproduce
This is my code
const express = require('express')
const { body, validationResult } = require('express-validator');
const app = express();
var HashMap = require('hashmap');
const port = process.env.PORT || 80;
var informationsMap = new HashMap();
/*setting the body parser*/
app.use(express.json());
app.listen( port,() => {
console.log (`Example app listening at http://localhost:${port}`)
})
app.get('/api/informations/:infoKey', (request, response) => {
response.setHeader('Content-Type', 'application/json');
response.end(JSON.stringify(informationsMap.get(request.params.infoKey)));
})
app.get('/api/informations' ,(request, response) => {
response.setHeader('Content-Type', 'application/json');
var responseValue = []
informationsMap.forEach(function (value , key ){
var element = {}
element.key = key;
element.value = value;
responseValue.push({elements:element});
})
response.end(JSON.stringify(responseValue));
})
app.post('/api/informations',[body('source').isString , body('sourceTime').isNumeric] , (request, response ) =>{
const errors =validationResult(request)
if (errors){
response.status(400).end(JSON.stringify(errors))
}else{
var key = request.body.source + "_" + request.body.sourceTime
informationsMap.set (key , request.body )
response.setHeader('Content-Type', 'application/json');
response.end(JSON.stringify({}))
}
})
Expected behavior
With the following call, I expected to return an error
curl --request POST \
--url http://localhost/api/informations \
--header 'Content-Type: application/json' \
--data '{
"source" : "some_device",
"sourceTime": "1619029756779",
"value" : 1.453543543534
}'
Current behaviour
It remains pending
Express-validator version:
- Version: 6.10.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
What does "pending" mean for request in Chrome Developer ...
The Network pending state on time, means your request is in progressing state. As soon as it responds the time ...
Read more >chrome requests get stuck pending - nginx - Server Fault
Open the network debugger in Chrome and try to reproduce a stuck request. It will show you an exact timeline: when the request...
Read more >Request stuck in pending state / promise never resolves #941
I am using chai HTTP module in the tests and I see there is some history with superAgent. Is there still open issue...
Read more >Help with Express JS, fetch request stays (pending) - Reddit
Hello, I am hoping someone can help me with my issue. On the front end I have a button to add new users....
Read more >XHR requests pending for a long time in recent Chrome ...
Sometimes I have to login/out of my site about two or three times before I get a pending request. After that, I get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fedeci My bad it works… Doohhh (Omar sounds) Thanks for your time
In the zip I can see that are still missing brackets after
body('foo').isNumeric
-> wrongbody('foo').isNumeric()
-> correct