Hi guys, I am trying to retrieve data from google ...
# suitescript
t
Hi guys, I am trying to retrieve data from google api and this is it return ..... Then I want to get the state island value. How do I do that? My code before is working (see below) now its not
if (restResponse.code == "200" && response.status == 'OK') {
var results = response.results[0].address_components;
results.forEach(function (_res_) {
//console.log(res)
if (_res_.types[0] == 'locality') {
resultsData["city"] = _res_.short_name
}
if (_res_.types[0] == 'administrative_area_level_1') {
resultsData["state"] = _res_.short_name
}
if (_res_.types[0] == 'country') {
resultsData["country"] = _res_.short_name
}
});
}
z
I would like to know: • how does this relate to NetSuite • how do I know what mean it was working but now doesn’t
s
You code block is overwriting the values on your
resultsData
.... you are only setting the values when the first 'type' is locality, administrative_area_level_1 or country
none of those things are true for Staten Island
t
Im calling this on my suitescript to get the state details
You are right @Sandii, i figure it out on my loop I log the
_res_.types[0]
to get the exact value and now its working
s
To Zoran's point, this is not a suitescript question. It is how to read data from a JSON object
thumbs up 2
t
my bad still thank you for taking time on reading this
👍 1