Wie man den Autor in WordPress API reagiert
import React, { Component } from "react"
...
class Blog extends Component {
static async getInitialProps() {
const postsRes = await fetch(`${Config.apiUrl}/wp-json/wp/v2/posts?_embed`)
const post = await postsRes.json()
return(post)
}
render() {
const posts = this.props.posts.map((post,index) => {
return(
<li key={index}>
{post.better_featured_image != null ? <Feat img=
{post.better_featured_image.source_url}/> : ""}
<Link
as={`/blog/${post.slug}`}
href={`/blog?slug=${post.slug}&apiRoute=post`}
>
<a>{post.title.rendered}</a>
<p>{post.author}</p> //Returns ID I need name
</Link>
</li>
)
})
}
Never look this up again
Southern Boubou