Reputation: 6281
I know this has been asked hundreds of times, however I've written loads of callback functions before and I think I've just gone a bit blind to my problem/
I have a function:
function firstSend(){
client.write(Buffer.from([0x5C,0x57,0x31,0x32,0x33,0x34,0x2F]));
check(function(msg){
if(msg == true){
console.log("Lets go");
}
});
}
That calls the function check
with a callback
The check function returns true when it is complete:
function check(callback) {
let m;
if(message != null) m = message.trim();
if(m != "OK"){
setTimeout(check, 1000);
return;
}
return callback(true);
}
Everything works correctly until it tries to do a callback, at which point it tells me its not a function.
I've logged callback out and it logs as a function, so i'm a little stumped
Upvotes: 0
Views: 87