Lets understand the callback fucntion in NodeJS using the below geocode example.
Here we have created geoCode function with two paramters, first parameter will take input of the location name and second parameter the function that needs to call. Similary, we can add or pass any number of paramters in fucntion as per need.
const geoCode = (location, callback) => {const data = {location: location,latitude: 0,longitude: 0}callback(data)}
geoCode('New Delhi', (callbackData) => {console.log(callbackData)});
{ location: 'New Delhi', latitude: 0, longitude: 0 }