The call on the api returns this json:
[
{
"RESULT": {
"TYPES": [
"bigint",
"varchar",
"varchar",
"varchar",
"varchar",
"varchar",
"date",
"varchar",
"int",
"int",
"varchar"
],
"HEADER": [
"kvk",
"bedrijfsnaam",
"adres",
"postcode",
"plaats",
"type",
"anbi",
"status",
"kvks",
"sub",
"website"
],
"ROWS": [
[
"273121520000",
"Kinkrsoftware", <-- this is the value i want
"Oude Trambaan 7",
"2265CA",
"Leidschendam",
"Hoofdvestiging",
null,
null,
"27312152",
"0",
null
]
]
}
}
]
I can't change the api code.
I am using Angular and I can't see to get access to the values.
This is my controller:
.controller('MainCtrl', function($scope, $http, $log, kvkInfo) {
kvkInfo.success(function(status, data) {
$scope.name = status;
$scope.bedrijf = data;
$scope.status = status;
});
});
I have tried
data.RESULT.ROW, data.RESULT.ROW[1], data.RESULT[0].ROW, data.RESULT[0].ROW[1], data.ROW[1]
How can i get this element?
What you get starts with [
, so it's an array. So you need data[0]
.
The first element of this array (data[0]
) is an object (it starts with {
) which has a RESULT attribute. So you can use data[0].RESULT
.
The value of the RESULT attribute is another object which has a ROWS
attribute (Note the final S
). So you can use data[0].RESULT.ROWS
.
The value of ROWS is an array, containing another array, so you need data[0].RESULT.ROWS[0][1]
.
Your api result is wrapped in an array, so you have to save the first element of it to the scope instead of the whole array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With