0

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();
 }


  });
8
  • Could you do console.log(response.data) into the promise ? And post output here ? Commented Dec 26, 2016 at 14:37
  • HI [Object { Id="50630", Id_cadastro="61693", Operador=""}] Commented Dec 26, 2016 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"}] Commented Dec 26, 2016 at 14:47
  • Okay, what if you change this line this.cervejarias = response.data; to this this.cervejarias = response.json(); Commented Dec 26, 2016 at 14:48
  • nothing n { promise=Promise, context=undefined, bind=function(), mais...} Commented Dec 26, 2016 at 14:55

1 Answer 1

-1

Consider adding:

header('Access-Control-Allow-Origin: *');

To your PHP pages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.