ILIAS ILIAS - 1 year ago 66
Javascript Question

Pass a variable inside tags argument of Flickr API

Here is my working code (in Angular):

var url ="

$http.jsonp(url).then(function(response) {
console.log(;},function(){console.log('Error retrieving JSON data')}

I do not know how to send to
a variable's value
and not just writing coffee or chocolate. Is there a better way to organize all this information (api_key, format, tags) in an object and append it to url?

Answer Source

You can use config.params object to set tags GET parameter:

var url = "";

$scope.tags = 'coffee';

$http.jsonp(url, {
  params: { tags: $scope.tags }
.then(function(response) {
}, function() {
  console.log('Error retrieving JSON data')