1.const geoCode = (address, callback)=> {
setTimeout(()=> {
const data ={
longitude: 0,
latitude: 0
}
callback(data)
})
}
geoCode('John', (data)=>{
console.log(data)
})
2. const forecast =(longitude, latitude, callback) =>{
const url = `https://api.openweathermap.org/data/2.5/weather?
lat=${latitude}&lon=${longitude}&appid=ff894a55e90b66e3d6cd4b2bd8ea6509`
console.log(url);
request({url, json:true}, (error, {body})=>{
if(error) {
callback('Unable to connect to the Internet', undefined)
} else if(body.error){
callback('Please try again', undefined)
} else {
callback(undefined,body.main)
}
})
}
Hi, I am new to Node.js and having a hard time understanding callbacks,callback queues and how it is processed. My question is what kind of callbacks goes to the callback queue in Node? Does it have to be callback that is inside of node specific APIS,npm packages and web APIs like setTimeOut,request(), to be added inside of callback queue to be executed after the main call stack is empty? or any kind of callbacks goes into the callback queue in node.js?