Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing a post API call that has a param with Postman

This is my API route in nodejs:

router.get('/reset/:token', function(req, res) {
  User.findOne({ resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) {
    if (!user) {
      res.json('Password reset token is invalid or has expired.');
      //return res.j('/forgot');
    }
    res.json('Goed');
  });
});

Now when I want to test this in Postman, I use this incorrect way:

Postman Screenshot

I normally don't work with params, how can I test this?

like image 964
stijn.aerts Avatar asked Mar 13 '23 22:03

stijn.aerts


2 Answers

You can use URL segment parameters like this:

URL: http://localhost:3000/reset/:id

And a URL parameter:

id = 65bb...

enter image description here

like image 143
zord Avatar answered Mar 24 '23 11:03

zord


2 issues. 1. In screen shot the method is POST but your code waiting for GET request. 2. use this url: http://localhost:3000/reset/6b.... do not use token=

like image 29
Ali Nikneshan Avatar answered Mar 24 '23 09:03

Ali Nikneshan