У меня возникли проблемы с получением фактических данных из возврата от вызова API.Я могу видеть значения, выводимые в журнал, но когда я пытаюсь получить к нему доступ, используя data [0] .admin_url , возвращается undefined .
this.apiService
.getCCUrls()
.then(function(data){
console.log(data); //output in the image below
console.log(data[0].admin_url); //returns undefined
});
Какойвызывает это:
APIService.prototype.getCCUrls = function() {
return this.makePublicApiRequest({
method: 'GET',
url: '/v1/cc-instances',
});
};
Между ними есть некоторый простой служебный код, но в конце концов он доходит до этой функции ...
APIService.prototype.makeRequest = function(config) {
return this.$http(config)
.then(function(response) {
// If we get a replacement token, update it.
this.authService.checkResponseHeaders(response);
var data = response.data;
if (data.data) {
return data.data;
}
if (data) {
return data;
}
return response;
}.bind(this));
};
Наконец, это то, что выводится в консоли.log:

Итак, в моем первом наборе кода, как мне получить переменные admin_url, agent_url или type?