lewisdale.dev/src/_data/posts.js

14 lines
400 B
JavaScript
Raw Normal View History

2023-02-15 20:38:52 +00:00
const wordpressPassword = process.env.WORDPRESS_PASSWORD;
module.exports = async () => {
const response = await fetch("https://lewisdale.dev/wp-json/wp/v2/posts?per_page=100", {
headers: {
"Authorization": `Basic lewis:${wordpressPassword}`
}
});
2023-02-16 08:34:36 +00:00
const posts = await response.json();
2023-02-15 20:38:52 +00:00
2023-02-16 08:34:36 +00:00
console.log(posts.map(post => Buffer.from(post.title.rendered).toString("utf-8")));
return posts;
2023-02-15 20:38:52 +00:00
};