Cannot jump after inserting database in express

  node.js, question
exports.adduser = function(db) {
 return function(req, res) {
 // Get our form values. These rely on the "name" attributes
 var userName = req.body.username;
 var userEmail = req.body.useremail;
 var collection = db.get('users');
 var llll = collection.insert({
 "userid": userName,
 "password": userEmail,
 })
 if (llll) {
 res.location('http://baidu.com');
 } else {
 res.send("error")
 bracket
 bracket
 };

The database was successfully inserted, but it will not jump to Baidu correctly.
The error was reported as 500typeerror: res.locationsnotafunction

What is the reason?

Just looked at it,res.locationYes settinglocationRequest header

res.location('/foo/bar');
 res.location('foo/bar');
 res.location('http://example.com');
 res.location('../login');
 res.location('back');

You can use andres.redirect()The same in insideurls.

For example, if your program root address is/blogThe following code puts thelocationThe request header is set to/blog/admin:

res.location('admin');

The following is the key point

Generally, back-end jump is usedres.redirect([status], url)(Optional status, default 302):

res.redirect('/foo/bar');
 res.redirect('http://example.com');
 res.redirect(301, 'http://example.com');