Auth0でlocal-mongoと呼ばれる新しいデータベース接続を作成しました。ローカルのmongoDBでユーザーを作成するためにCreateスクリプトを使用しようとしていますが、このソケットハングアップエラー:次のようにAuth0 - Auth0でlocalhost上でmongoDBを使用する方法
[Error] Error: socket hang up
at createHangUpError (_http_client.js:211:15)
at Socket.socketOnEnd (_http_client.js:303:23)
at emitNone (events.js:72:20)
at Socket.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:913:12)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickDomainCallback (node.js:397:17)
Auth0で作成したスクリプトのテンプレートは次のとおりです。
function create (user, callback) {
mongo('mongodb://localhost:27107.com/my-db', function (db) {
var users = db.collection('users');
users.findOne({ email: user.email }, function (err, withSameMail) {
if (err) return callback(err);
if (withSameMail) return callback(new Error('the user already exists'));
bcrypt.hash(user.password, 10, function (err, hash) {
if (err) { return callback(err); }
user.password = hash;
users.insert(user, function (err, inserted) {
if (err) return callback(err);
callback(null);
});
});
});
});
}
は、私は地元のDBに接続するか、またはするためにngrokが必要です私は「別の方法がありますここに行方不明?どんな助けでも大歓迎です。
ガー、私はそれが私の頭の中でどのようにmlabでテストするのか分かりませんでした。それを使用するとうまく動作します。私は、他の方法でもAPIの間で試してみます。私のアプリはReactとExpressで作られているので、あなたの提案はうまくいくはずです。ご助力ありがとうございます。 – aroundsix
よろしくお願いします!答えを認めていただきありがとうございます:) – arcseldon