router.post("/",middleware.isLoggedIn ,upload.single("image"),function(req, res){
geocoder.geocode(req.body.place.location, function(err, data){
while(status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT)
{
setTimeout(3000);
}
if ( err){
req.flash("error", err.message);
console.log("error");
return res.redirect("back");
}
req.body.place.lat = data[0].latitude;
req.body.place.lng = data[0].longitude;
//cloudinary configuration
cloudinary.uploader.upload(req.file.path, function(result){
// add cloudinary url for the image to the campground object under image property
req.body.place.image = result.secure_url;
// add author to campground
req.body.place.author = {
id: req.user._id,
username: req.user.username
};
Place.create(req.body.place, function(err, newlyCreated){
if(err){
res.send(err);
}else{
res.redirect("/");
}
});
});
});
});

答案 0 :(得分:0)
From GOOGLE documentation concerning query limits
"收到状态代码为OVER_QUERY_LIMIT的响应后,您的应用程序应确定已超出哪个使用限制。这可以通过暂停2秒并重新发送相同的请求来完成。如果状态代码仍为OVER_QUERY_LIMIT,则您的应用程序每天发送的请求过多。否则,您的应用程序每秒发送的请求过多。"
您的第一步需要是2秒超时才能确定原因。如果每秒太多,请减少,直到您不再收到错误为止。
镉&安培;