0

I've bulid a small app that get data from http://open-notify.org/Open-Notify-API/ISS-Pass-Times/ and dispalys it in a table. Since i'm new to vue i don't understand why i can't set the data to the view. I've created a dummy component calls "cell" which looks like this :

Vue.component("cell", {
   template: '<ul>'
   +'<li v-for="foo of apiData">'
   +' {{foo}} '+
  '</li></ul>',
  props:['apiData']
 })

In the view i've called it like this :

 {{apiData|json}} // trying to get a preview of data
  <cell></cell> // calling component

And keep getting an empty object - i guess it's because the api call is taking a few seconds more than the markup is loaded....

Fiddle

RoyBarOn
  • 919
  • 3
  • 24
  • 63
  • Where are you passing apiData to cell? – Devon Bessemer Jul 17 '18 at 22:44
  • @Devon Thanks, it's being passed in the props of the component... props:['apiData'] – RoyBarOn Jul 17 '18 at 22:45
  • 1
    No, that's where it's declared, where is it being passed? – Devon Bessemer Jul 17 '18 at 22:46
  • If you define a property on cell, you still have to pass data to that component via that property. I.E. `` – Devon Bessemer Jul 17 '18 at 22:49
  • @Devon Thanks again, the problem is that i can't display the data from the api - i've set a varible called apiData - to store the response - but i keep getting an empty object... as i've said - i think it's caused by a delay of the request.....any ideas? thanks – RoyBarOn Jul 17 '18 at 22:53
  • Yeah, you've got quite a few problems in your code from a brief review. You might want to narrow down your question, or narrow down your code, and work on one piece at a time. – Devon Bessemer Jul 17 '18 at 22:54
  • @Devon Thanks, i'm not sure what to narrow down exactly since nothing except the cell component - is relevant to the problem.... sure would be nice if you'll give some tips. thanks, – RoyBarOn Jul 17 '18 at 23:00
  • 2
    You have a scope issue (your axios callback is a regular function). Here is your fiddle updated. https://jsfiddle.net/de31hv9w/4/ – Bert Jul 17 '18 at 23:46
  • @Bert - Oh.... got it thanks!!! – RoyBarOn Jul 18 '18 at 13:56

0 Answers0