Hello, I'm following a tutorial on callbacks and I have this error ReferenceError: callback is not definedThis is my code, can someone explain to me what is going on? Questions with the same title have usually minus score on StackOverflow so I don't even bother.const request = require('request'); var geocodeAddress = (address) => { var encodedAddress = encodeURIComponent(address);request({ url: https://geocoder.tilehosting.com/q/${encodedAddress}.js?key=x8vHgk5z1xKTbpmVhCOb, json: true }, (error, response, body) => { if (error) { callback('Unable to find data'); } else if (body.totalResults === 0) { callback('Unable to find the location'); } else if (body.totalResults > 0) { callback(undefined, { address: body.results[0].display_name, latitude: body.results[0].lat, longitude: body.results[0].lng }); } }); };module.exports.geocodeAddress = geocodeAddress;
Submitted December 04, 2018 at 04:36PM by FreeShaman
No comments:
Post a Comment