1
我想打電話給一個function.so內的回調函數,我不知道該怎麼做如何在函數內部使用回調函數?
function call(){
pg.connect(conString, function(err, client, done) {
if(err) {
return console.error('error fetching client from pool', err);
}
client.query('INSERT into post1 (data) VALUES ($n)', function(err, result) {
//call `done()` to release the client back to the pool
done();
if(err) {
return console.error('error running query', err);
}
console.log(result.rows[0].number);
//output: 1
});
});
}
board.on("ready", function() {
// Create a new generic sensor instance for
// a sensor connected to an analog (ADC) pin
var sensor = new five.Sensor("A0");
// When the sensor value changes, log the value
sensor.on("change", function() {
var n = this.value();
//i want to call that function here
});
});
,我也想調用這個函數在另一個回調函數,這是做正確的方式或建議我是正確的。
爲什麼ü通過回調呢? – RajaRaman
抱歉一定沒有理解你的問題,你想達到什麼目的? – JanR
回調(結果); –