Skip to content

Instantly share code, notes, and snippets.

@saboyutaka
Created September 14, 2021 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saboyutaka/0dc11a6712c6e25bbce83f60697c7022 to your computer and use it in GitHub Desktop.
Save saboyutaka/0dc11a6712c6e25bbce83f60697c7022 to your computer and use it in GitHub Desktop.
wpapi
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