Search code examples
javascriptjsonpflickr

flickr api - getting photos with JSONP


I have the following script:

import "./index.scss";

import jsonp from 'jsonp';

(function() {
    jsonp("https://api.flickr.com/services/feeds/photos_public.gne?format=json", (err, data) => {
        console.log(err)
    })
})();

and I am trying to receive the response from Flickr, and i get this error:

Uncaught ReferenceError: jsonFlickrFeed is not defined

what am i doing wrong?


Solution

  • Flickr doesn't support the callback query string parameter which standard JSONP APIs use to pick the callback name and hardcodes jsonFlickrFeed instead.

    You can override the name the jsonp client library expects with the name option as per the documentation