// state edit route
app.get("/map/:symbol/edit", isLoggedIn, function(req, res){
State.findOne({symbol: req.params.symbol}, function(err, state){
if(err){
console.log(err);
} else
{
res.render("edit", {state: state});
}
});
});
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中,isLoggedIn是检查身份验证的中间件函数。其定义如下:
// middleware function
function isLoggedIn(req, res, next){
if(req.isAuthenticated()){
return next();
}
res.redirect("/admin");
}
Run Code Online (Sandbox Code Playgroud)
那么,问题是,如何将字符串、整数或路径变量等参数传递给中间件函数,以便可以在路由 url 中使用?
我正在尝试为 Android 构建我的 React-Native 项目,并在 Windows 上收到以下错误,但它在 Mac 上工作。
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1090 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Task :react-native-get-sms-android:generateDebugRFile FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
128 actionable tasks: 128 executed
FAILURE: Build …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ReactJS 创建一个录音机应用程序。我使用 npm 包React-mic来达到这个目的。但录音被保存为blob对象。
如何在浏览器中播放录制的文件(blob对象)?以及如何将其作为音频文件上传到在线存储?(如火力基地)
尝试从远程节点进行转储并收到以下错误:
失败:无法创建会话:无法连接到服务器:connection():身份验证错误:sasl 对话错误:无法使用机制“SCRAM-SHA-256”进行身份验证:(身份验证失败)身份验证失败。
尝试了两种方法从远程节点获取转储。但是在这两种方法中都出现了相同的错误。
# Method 1
mongodump -h remoteip@port -u xxx -p xxx --db xxx --authenticationDatabase xxx
# Method 2
mongodump --uri "mongodb://username:password@remoteip:port/db?authSource=xxx"
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?