Closed phoenisx closed 5 years ago
Yup, I'm having the same problem too
var express = require('express');
var app = express();
var port = process.argv[2];
app.put('/message/:id', function(req,res) {
res.send(require('crypto')
.createHash('sha1')
.update(new Date().toDateString() + req.param.id)
.digest('hex'));
})
app.listen(port);
@Shub1427 @acrenwelge
parameters from within the request handlers, use:
req.params.NAME
It's req.# params, not req.# param
Your submission results compared to the expected:
ACTUAL EXPECTED
────────────────────────────────────────────────────────────────
"56b1b7981edc3f048173b5168d4d5c59cd90b0be" != "2a604ba8cfc3c332609b71fa07688ec79cc7bf99"
────────────────────────────────────────────────────────────────
✗ Submission results did not match expected!
var express = require('express');
var app = express();
app.put('/message/:id', function(req, res){
var id = req.params.id;
var str = require('crypto')
.createHash('sha1')
.update(new Date().toString() + id)
.digest('hex');
res.send(str);
});
app.listen(process.argv[2]);
@smachen This solution doesn't work as well.
I found my mistake. It should be new Date().toDateString()
and not new Date().toString()
.
Always getting a different value than expected, even though the program is as expected..