Ok guys..i이 코드를 봤기 때문에 코드에 오류가 표시되지 않습니다. 내 코드는 DB 벌금에 연결되고 내 콘솔 로그 내가 다시 돌려받을하고자하고있는 무슨이다Node.js 오류 TypeError : 객체가 콜백의 함수가 아닙니다.
{ id: 7,
name: 'Tap\'s',
quicklist: 'Y',
message: 'Welcome..enjoy one of our many craft brews!',
fbflag: 'Y',
facebookurl: 'https://www.facebook.com/TapsPourhouseMooresville',
twflag: 'Y',
twitterurl: 'https://twitter.com/TapsPourhouse',
contactflag: 'Y',
contactemail: '[email protected]',
eventsflag: 'Y',
loyaltyflag: 'Y',
loyaltyclub: 'TAPped In',
loyaltymessage: 'Become a member of the TAPped In Club in order to receive special offers and to stay informed on upcoming events and exclusive offers!',
locdescription: 'Table 10' }
로 내 결과를 보여주는하지만 형식 오류가 계속 : 객체가 라인을 참조하는 기능 아니다 아래에 댓글을 달았습니다.
exports.get_site_setup = function (callback) {
var dbc;
async.waterfall([
// get a connection
function (cb) {
// if (!name)
// cb(backhelp.missing_data("site name"));
// else
db.db(cb);
},
function (dbclient, cb) {
dbc = dbclient;
dbc.query("select s.ID as id, s.NAME as name, s.QUICK_LIST_ENABLED as quicklist, s.MESSAGE as message, s.FBFLAG as fbflag, "+
"s.FACEBOOKURL as facebookurl, s.TWFLAG as twflag, s.TWITTERURL as twitterurl, "+
"s.CONTACTFLAG as contactflag, s.CONTACTEMAIL as contactemail, s.EVENTSFLAG as eventsflag, "+
"s.LOYALTYFLAG as loyaltyflag, s.LOYALTYCLUB as loyaltyclub, s.LOYALTYMESSAGE as loyaltymessage, l.LOCDESC locdescription "+
"from COMPANIES as c "+
"left join SITES as s on c.ID = s.COMPANY_ID "+
"left join LOCATION as l on s.ID = l.SITE_ID "+
"where c.ID = 7 and s.ID = 7 and l.ID = 8",
cb);
}
],
function (err, results) {
if (dbc) {dbc.end();}
if (err) {
callback(err);
} else if (!results || results.length === 0) {
// callback(backhelp.no_such_site());
} else {
callback(null, results[0]); // <-- Error on this line
console.log(results[0]);
}
});
};
당신은 데이터를 잡으려고 전역을 설정하지, 콜백을 통해 데이터를 다시 전달해야한다. – adeneo
을 또한, 당신은 단지를 전달할 수 없습니다 매개 변수'dbclient'를 사용하고 갑자기 두 번째 매개 변수가 콜백이 될 것으로 예상하십시오. – adeneo
@adeneo 당신이 나를 위해 정교하게 만들 수 있습니까? – ddpishere