Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Pagination from "@77io/pagination";
- import { last, reduce } from "rxjs/operators";
- // Setup the basic options
- const baseUrl = wordpressRoot + "/wp-json/wp/v2/posts";
- const headers = {
- accept: "application/json"
- };
- const sub = Pagination(baseUrl, headers)
- .pipe(
- reduce((arr: any[], page: any[]) => {
- return arr.concat(page);
- }, []),
- last()
- )
- .subscribe((allPosts: any[]) => {
- console.log("I got all posts!");
- sub.unsubscribe();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement