我正在创建一个NodeJs应用程序。我需要在其中具有以下功能。
我有以下代码
function abc() {
var liB = document.querySelectorAll('li')
, liBArray = Array.prototype.slice.call(document.querySelectorAll('li'))
, icons = document.querySelectorAll('li i')
, iconsArray = Array.prototype.slice.call(document.querySelectorAll('li i'));
//MOUSEOVER
function changeI() {
'use strict';
if (iconsArray.length) {
for (var i = 0; i < icons.length; i++) {
iconsArray[i].style.fontSize = '2em';
}
}
}
//MOUSEOUT
function backI() {
'use strict';
if (iconsArray.length) {
for (var i = 0; i < icons.length; i++) {
iconsArray[i].style.fontSize = '1em';
}
}
}
if (liBArray.length) {
for (var i = 0; i < liB.length; i++) {
liBArray[i].addEventListener("mouseover", changeI);
liBArray[i].addEventListener("mouseout", backI);
}
}
}
abc();
在这一行:
var options = {
host: 'maps.googleapis.com',
path: '/maps/api/geocode/json?&address=' + donor[j].pincode + '&key=AIzaSyD4M1TkzIl0nyKObyXtrCOgHJpN_BDPb6A'
}
https.request(options, callback).end();
callback = function (response) {
var str = '';
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
var loc = JSON.parse(str);
console.log(loc.results[0].geometry.location.lat);
Donor.collection.updateOne({email: email},
{ $set: { latitude: loc.results[0].geometry.location.lat, longitude: loc.results[0].geometry.location.lat } },
false,
true);
});
}
我想从调用函数传递电子邮件字段以检查Donor.collection.updateOne({email: email},
{ $set: { latitude: loc.results[0].geometry.location.lat, longitude: loc.results[0].geometry.location.lat } },
false,
true);
并更新email
和latitide
。
我将如何做到这一点?