我在jotform中有一个表单,它通过zapier到[spatula.io] [1],一切正常,直到错误开始发生:
TypeError: Cannot read property 'geometry' of undefined eval (eval at <anonymous> (/var/task/index.js:52:23), <anonymous>:47:39) process._tickDomainCallback (internal/process/next_tick.js:135:7)
我知道它与谷歌API有关,但我不知道为什么或什么是错的。 谢谢。
output = [{id: 123, hello: "world"}];var key = 'AIzaSyBSgUahDolVIFG3q4ogCZMOBoyZXTW78UM ';
var address = {};
input.address.split(/[\n\r]+/).forEach(function(line) {
var parts = line.split(': ');
address[parts[0].toLowerCase().replace(/\s+/g, '')] = parts[1];
});
var __x = {
streetname: 'Maple Avenue',
housenumber: '746',
city: 'Glenside',
state: 'PA',
postalcode: '19038'
};
var formattedAddress = [
address.housenumber,
address.streetname,
address.city,
address.state,
address.postalcode
].join(' ');
fetch(
'https://maps.googleapis.com/maps/api/geocode/json?key=' +
key +
'&address=' +
encodeURIComponent(formattedAddress)
)
.then(function(res) {
return res.json();
})
.then(function(body) {
callback(null, {
address: formattedAddress,
geocodeResult: body.results[0].geometry.location
});
})
.catch(callback);