Created
October 29, 2019 14:09
-
-
Save naz/b71619cb04d35e0de97a91f8b41f95a0 to your computer and use it in GitHub Desktop.
Fetch all posts from Ghost API
This file contains 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
// USAGE: node admin-read-posts.js http://localhost:2368 ADMIN_API_KEY | |
if (process.argv.length < 4) { | |
console.error('Missing an argument'); | |
process.exit(1); | |
} | |
const url = process.argv[2]; | |
const key = process.argv[3]; | |
const GhostAdminAPI = require('@tryghost/admin-api'); | |
const api = new GhostAdminAPI({ | |
url, | |
key, | |
version: 'v3' | |
}); | |
(async function main() { | |
try { | |
let posts = await api.posts.browse({limit: 'all'}); | |
console.log(posts); | |
} catch (e) { | |
console.log(e); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment