Hi guys, i have very basic project that i must be finish in two days but i have some issues.
My ControllerJs Code;
$scope.dataBack={};
$scope.calculate = function(a,b){
console.log("Start: "+ a, "Finish: "+ b);
$http.post('https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins='+a+'&destinations='+b+'&mode=driving&departure_time=now&traffic_model=optimistic&key=AIzaSyD4Q7mPb9XhS5i0KvgsCfi-ahKB-rooqOI')
.then(function(data){$scope.dataBack = data;
});
};
The question is, there is Google APİ above as you can see and ı want to take a single data from this APİ.
This api turns JSON back.ım trying to reach a “value” data of this JSON but ı cant.
ım coding like ;
console.log($scope.dataBack.rows[0].elements[0].duration_in_traffic.value);
but it turns back error about tha code above.
How am i suppose to do the JSON convert part? I think the problem is about JSON.
Please help me thanks.
EDİT: Btw the output of link is something like that;
{
"destination_addresses" : [ "Rize, Rize Merkez/Rize, Türkiye" ],
"origin_addresses" : [ "Ordu, Türkiye" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "204 mil",
"value" : 328881
},
"duration" : {
"text" : "4 saat 48 dakika",
"value" : 17270
},
"duration_in_traffic" : {
"text" : "4 saat 32 dakika",
"value" : 16315
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}