1
note the Javascript code below;
var app = new Vue({
el:'#app',
data:{
bancodedados:[]
},
methods:{
},
created:function(){
var self = this;
self.$http.get('https://swapi.co/api/planets/1/?format=json').then(function(response){
/*console.log(response); */
self.bancodedados = response.data;
});
}
});
This is my page;
<table class="table">
<thead>
<tr>
<th>nome</th>
<th>Title</th>
<th>Nome</th>
</tr>
</thead>
<tbody>
<tr v-for="bancodedado in bancodedados">
<td>{{ bancodedado.name }}</td>
<td>{{ bancodedado.climate }}</td>
<td></td>
</tr>
</tbody>
</table>
What is happening is that he is able to load all the list but I can’t visualize as shown below;
Maybe the problem is in html code, just need to know how to fix;
====================================================================
see what appears on my consoles;
gave this result with this command;
console.log(response);
That means he can load the Json records!
but if it’s with that command;
consoles.log(this.bancodedados);
is quite different;
what appears if Voce gives a
console.log(this.bancodeados)
?– Rafael Augusto
I just modified my post, could you take a look please.
– wladyband
bancodedados must have a json of the response, by the console print, json is not in Response, but in Response.body. Try to put it that way:
self.bancodedados = response.data.body;
and see for sure– Samuel Rizzon
It would actually be
self.bancodedados = response.body;
. But this json is not a list/array as you expect, it is a single object, with data from only one planet.– bfavaretto