Created
September 14, 2021 13:40
-
-
Save saboyutaka/0dc11a6712c6e25bbce83f60697c7022 to your computer and use it in GitHub Desktop.
wpapi
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
import WPAPI from "wpapi"; | |
import { WP_REST_API_Posts } from "wp-types"; | |
const wp = new WPAPI({ endpoint: "https://your.wordpress.com/wp-json" }); | |
async function main() { | |
const posts: WP_REST_API_Posts = await wp.posts().get(); | |
const contents = posts.map(p => p.content.rendered) | |
console.log(contents); | |
} | |
main().catch(err => { | |
console.error(err); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment