Last active
April 11, 2021 08:09
-
-
Save hubgit/c0ee395e8e500fbcd2aa4668c2c5e0bf to your computer and use it in GitHub Desktop.
Fetch the collection of COVID-19/SARS-CoV-2 preprints metadata from medRxiv and bioRxiv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://api.biorxiv.org/covid19/help | |
| let cursor = 0 | |
| do { | |
| const url = `https://api.biorxiv.org/covid19/${cursor}` | |
| const response = await fetch(url) | |
| const { messages: [message], collection } = await response.json() | |
| console.log(message) | |
| if (message.status !== 'ok') { | |
| break | |
| } | |
| for (const item of collection) { | |
| yield { item } | |
| } | |
| cursor += message.count | |
| yield { progress: { value: cursor, max: message.total }} | |
| if (cursor > message.total) { | |
| break | |
| } | |
| } while (true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment