Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does subcollections() work? #13

Closed
cboulanger opened this issue Dec 13, 2019 · 2 comments
Closed

Does subcollections() work? #13

cboulanger opened this issue Dec 13, 2019 · 2 comments

Comments

@cboulanger
Copy link

Hi, probably I am doing something wrong, but I don't get subcollections to work:

const api = require('zotero-api-client');
const lib1  = api(process.env.ZOT_API_KEY).library("user",12345);
(async ()=>{
  let response = await lib1.subcollections().get();
  let collectionData = response.getData();
  console.log(collectionData);
})();

Expected result: JSON data for only the top-level collections
Actual result: JSON data for 25 random collections

@tnajdek
Copy link
Owner

tnajdek commented Dec 13, 2019

subcollections can only be used when requesting collections existing underneath another collection. In the example you've posted it should be rejected (but isn't because #2 is not yet implemented) since you haven't specified a parent collection.

For top-level collections, the correct keyword is top, I believe in your example it would be lib1.collections().top().get().

An example where subcollections could be used, getting all subcollections living under a collection with a key "AABBCCDD":

lib1.collections("AABBCCDD").subcollections().get()

@cboulanger
Copy link
Author

Yes, this worked! Thanks so much for your quick response. It might make sense to update the documentation on subcollections() so that "Should only be used in conjuction with both library() ..." is not misunderstood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants