0
내 userProfileController.js 결과에서 데이터를 얻을 수있는 것은내가 thinky.io에서 데이터를 뽑을 수 있지만 내가
var UserProfileSerice = require('../../Services/User/UserProfileService.js');
module.exports = function(app){
app.get('/tester' , ensureAuthenticated, function(req, res){
var sonuc ;
UserProfileSerice.getUserByEmail(function(result){
sonuc = result;
})
console.log('sonuc' +sonuc);
res.render('UserPages/userPage');
})
}
및
이 기능이 UserProfileSerice 안에 정의되지 않습니다. js 파일 콜백이 작동하지 않습니다.
var UserModel = require('../../Models/User/UserModel.js');
var thinktConfig = require('../../Utils/rethinkdb/config.js');
var thinky = require('thinky')(thinktConfig.rethinkdb);
module.exports ={
getUserByEmail : function (callback) {
UserModel.filter({email: "[email protected]"}).run().then(function(result) {
callback(result);
});
}}
otherMethod
에서 올바른 결과를 확인한다이 방법을: 당신은 뭔가를해야 할 것인가? 그 노드가 완전히 비동기 적이기 때문에, 당신이하고있는 것처럼 콜백 바깥에서 값을 재사용하는 일은 드물다. – QuantumLicht
예 otherMethod가 작동 중입니다. 감사합니다 @ QuantumLicht,하지만 변수에 내 결과를 할당 할 수 없습니다 – slmkrnz
@slmkrnz 무엇을하려고하는지 더 자세히 알려주십시오. 나는 너를 다르게 도울 수 없다. – QuantumLicht