Comments (3)
Don't set up new instances of the Flickr API every time the route gets called. It's not a constructor, but a full API object builder; call it once, and then bind the flickr
instance for use in your own API:
let flickr = false;
let flickrOptions = { api_key, secret };
Flickr.tokenOnly(flickrOptions, function(err, flickrObject) {
if (err) {
return console.error(err);
}
console.log('flickr', flickrObject);
flickr = flickrObject;
});
app.post('/', function(req, res) {
const { text } = req.body;
if (!flickr) {
return res.status(500).json({ error: 'flickr not ready yet' });
}
flickr.photos.search({
text,
content_type: 1,
per_page: 100,
page:1
}, function(err, result) {
console.log('result', result);
res.send(result);
});
});
I don't see an if (err) console.error(err)
in your code to check whether the api object creation succeeded or not, so at the very least you'll want to add that in.
from node-flickrapi.
Sweet it works now. I really appreciate it!!
from node-flickrapi.
no problem, good to hear it works now.
from node-flickrapi.
Related Issues (20)
- overhaul the code to ES6, with as much code replaced by now-available packages. HOT 6
- Uploading an image results in an empty array and the application hanging HOT 12
- Access granted doesn't include write permissions HOT 4
- Pass on the error code from Flickr to the callback function.
- Sort many photosets with 'flickr.photosets.orderSets' fails (URI too long) HOT 5
- Video support? HOT 1
- Can't get original photos, not authenticated HOT 5
- Add `Flickr.proxy` to obviate `new Flickr` when proxying.
- TypeError: Cannot read property 'photos' of undefined HOT 1
- Document a note about building the IA index. HOT 3
- No results when using min/max_taken_date HOT 7
- Authorization from an Electron App HOT 6
- Issue with long load times for initiating the Flickr API HOT 11
- Part of string can't setMeta() HOT 1
- API is broken HOT 6
- Adding ability to add default options for request. HOT 4
- does API supported URL, streaming, buffer upload ? HOT 3
- Cannot find module './src/FlickrApi HOT 3
- Returned photo results are insufficient, photo property only contains five photo objects when there are clearly more photos HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-flickrapi.