Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm trying to consume an API and the $ http.get only returns NULL. I call a PHP that returns a json

What nonsense am I doing?

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.7/vue.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-  resource.min.js"></script>
<div id="app">{{cervejarias}}</div>


new Vue({
el:'#beerApp',

data:{
cervejarias: null
},
methods:{
getChamados: function(){
    this.$http.get('listar_cervejarias.php').then(function(response){
        this.cervejarias = response.data;
    }, function(error){
        console.log(error.statusText);
    });
 }
},
 mounted: function () {
 this.getChamados();
 }


  });
share|improve this question
    
Could you do console.log(response.data) into the promise ? And post output here ? – Belmin Bedak Dec 26 '16 at 14:37
    
HI [Object { Id="50630", Id_cadastro="61693", Operador=""}] – Nixon Girard Dec 26 '16 at 14:46
    
If json [{"Id":"50630","Operador":"","Id_cadastro":"61693"}] Not WORK {"Id":"50630","Operador":"","Id_cadastro":"61693"} Work My Php return [{"Id":"50630","Operador":"","Id_cadastro":"61693"}] – Nixon Girard Dec 26 '16 at 14:47
    
Okay, what if you change this line this.cervejarias = response.data; to this this.cervejarias = response.json(); – Belmin Bedak Dec 26 '16 at 14:48
    
nothing n { promise=Promise, context=undefined, bind=function(), mais...} – Nixon Girard Dec 26 '16 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.