我有一个Angular2服务
.switchMap(this::getStarredRepos)
向
发送请求logIn (username, password): Observable<User[]> {
return this.http.get(this.getUserUrl + username + '/' + password)
.map(this.extractData)
.catch(this.handleError);
}
但是我需要一种方式来发送router.get('/authenticate/:username/:password', function(req, res, next) {
schema.User.find({ username: req.param("username"), password: req.param("password")}).exec(function (err, users) {
if (err)
return console.error(err);
console.log("Load success: ", users);
res.send(users);
});
});
,尤其是username
以一种不会将其公开给请求本身的方式
答案 0 :(得分:1)
您可以将方法更改为发布
logIn (username, password): Observable<User[]> {
return this.http.post(this.getUserUrl + "test", {username: username, password: password})
.map(this.extractData)
.catch(this.handleError);
}
节点:
router.post('/authenticate/test', function(req, res, next) {
var username = req.body.username;
var password = req.body.password;
schema.User.find({ username: username, password: password }).exec(function (err, users) {
if (err)
return console.error(err);
console.log("Load success: ", users);
res.send(users);
});
});