question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

POST call remains pending

See original GitHub issue

Describe 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 image

Express-validator version:

  • Version: 6.10.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bmaschiocommented, Apr 22, 2021

@fedeci My bad it works… Doohhh (Omar sounds) Thanks for your time

1reaction
fedecicommented, Apr 22, 2021

In the zip I can see that are still missing brackets after body('foo').isNumeric -> wrong body('foo').isNumeric()-> correct

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found