I've been working on integrating an API with AngularJS and trying to display the data using ng-repeat, but I'm facing challenges in accessing the object's information.
Below is the feedback I received:
(20) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {name: 'bulbasaur', url: 'https://pokeapi.co/api/v2/pokemon/1/'}
1: {name: 'ivysaur', url: 'https://pokeapi.co/api/v2/pokemon/2/'}
2: {name: 'venusaur', url: 'https://pokeapi.co/api/v2/pokemon/3/'}
3: {name: 'charmander', url: 'https://pokeapi.co/api/v2/pokemon/4/'}
...and more
$$hashKey: "object:3" length: 20
<script>
angular.module('Pokedex', []).controller('myController', function ($scope, $http) {
$scope.pokemons = []
let getPokemons = function () {
$http.get('https://pokeapi.co/api/v2/pokemon/?offset={qtd')
.then(function (res) {
let pokemon = res.data.results
console.log(pokemon)
$scope.pokemons.push(pokemon)
})
}
getPokemons()
})
</script>
<body ng-controller="myController" ng-app="myapp">
<div>
<ul>
<li ng-repeat="pokemon in pokemons">
<h2>{{ pokemon.name }}</h2>
</li>
</ul>
</div>
I am currently only able to access the name by doing `pokemon[0].name`. I attempted to use map to access the array data, but faced difficulties due to being unfamiliar with this version of Angular. Can anyone point out where I might be going wrong?