Consuming an API field

Associate
OP
Joined
10 Jan 2006
Posts
483
Hmm doesnt seem to work I am getting an error - I have solved the CORS issue so thats not a problem.

What I don't understand it why the web page does not look like a normal JSON page
 
Associate
OP
Joined
10 Jan 2006
Posts
483
SyntaxError: Unexpected token '
at Object.parse (native)

I was getting a response fine with the previous but for some reason it doesnt like the jsoncallback=1..
 
Associate
OP
Joined
10 Jan 2006
Posts
483
Code:
this.getPhoto = function(){
    console.log('gettinghere')
    $http
    .get('https://api.flickr.com/services/feeds/photos_public.gne?tags=potato&tagmode=all&format=json&nojsoncallback=1')
    .then(function(response){
      var photoData = response.data
      console.log(photoData)
      self.addPhoto(photoData)
    })
    // self.newPhoto = '';
  }

  self.addPhoto = function(photoData){

    var newPhotoObject = {
      title: photoData['title']
    }
    // console.log(newPhotoObject)
    self.photos.push(newPhotoObject);
    var newPho = new Photo(newPhotoObject);
    newPho.$save(function(){
      newPhotoObject = {}
    });
  }
 
Associate
OP
Joined
10 Jan 2006
Posts
483
that's weird I have never put angular in JS fiddle before - It seems to think the flickrApp does not exist - but I defined it in the JS at the top and in the HTML
 
Back
Top Bottom