Open whiki opened 6 years ago
getNear is not working for me, saying getNear is not a function
Hi, have the same issue. could not find GeoJSON object file on GeoJSON side. is it in a branch?
Yeah in the video he mentions using the Ninjas.geoNear
function but in the Postman software it outputs as geoNear is not function, how to solve that
I've even read the official documentation about the geoNear
function but it sounds something more fishy. I don't understand that much. If this can not be solved someone can please help me understand what is going on, and why is the geoNear
function not recognising itself.
Funny enough, even VSCode didn't automatically suggested the
geoNear
function
EDIT: do I have to install those additional file of MongoDB to use the geoNear
function like the main bundle might not have those location functions and one might need to add additional libraries to use those. This is a doubt I have in mind, any help suggestion is appreciated
the documentation shows some aggregation parameter/callback as well, what is that ? https://docs.mongodb.com/manual/reference/operator/aggregation/geoNear/
The latest version of mongoose does not support geoNear. you might have to roll back to version 4 of mongoose.
router.get('/ninjas', (req, res, next) => {
Ninja.aggregate().near({
near: {
'type': 'Point',
'coordinates': [parseFloat(req.query.lng), parseFloat(req.query.lat)]
},
maxDistance: 100000,
spherical: true,
distanceField: 'dis'
}).then(ninjas => res.send(ninjas));
});
I got this solution from comments on the YouTube channel. It works for me. I think you should give it a try.
@krisdotcode okay sure, though for me it was more like it wasn't able to load the GeoJSON API, but anyways thank you
You didn't include the GeoJSON object file