nl_tokens: promise Flickr API request
pl_tokens: function ( tagArgs ) { if ( ! APIKey ) { throw new Error ( 'flickr_api_key configuration is required' ) ; } var tag = tagUtil . convertAttr ( tagArgs ) ; return new Promise ( function ( resolve , reject ) { var flJson = getFlickrCacheJson ( tag . id ) ; if ( ! flJson ) { // console.log("[api access getInfo]photoId= " + tag.id); var url = 'https://api.flickr.com/services/rest/?method=flickr.photos.getInfo' + '&api_key=' + APIKey + '&photo_id=' + tag . id + '&format=json' + '&nojsoncallback=1' ; https . get ( url , function ( res ) { var data = '' ; res . on ( 'data' , function ( chunk ) { data += chunk ; } ) ; res . on ( 'end' , function ( ) { var json = JSON . parse ( data ) ; if ( json . stat === 'ok' ) { pushFlickrJson ( json ) ; resolve ( tagUtil . imgFormat ( tag , json ) ) ; } else { return reject ( 'Flickr Tag Error: ' + tag . <mask> + ' ' + json . message ) ; } } ) ; } ) . on ( 'error' , function ( e ) { return reject ( 'Fetch Flickr API error: ' + e ) ; } ) ; } else { // console.log("[cache getInfo]photoId= " + tag.id); return resolve ( tagUtil . imgFormat ( tag , flJson ) ) ; } } ) ; }