Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get author in wordpress api react

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: service erstellen angular 
Javascript :: gitignore jsconfig 
Javascript :: minutes to seconds javascript 
Javascript :: can not found jstl core xml file 
Javascript :: load mulitple elements in route v6 
Javascript :: appolo query data in angular graphql 
Javascript :: jquery redirect to another page on radio button 
Javascript :: convert text file to string javascript 
Javascript :: express pass data between middleware 
Javascript :: why typescript is superset of javascript 
Javascript :: get position of an object inside a container phaser 3 
Javascript :: Private slots are new and can be created via Private slot checks 
Javascript :: how do i make http post in nodejs without third party 
Javascript :: nodejs post req accept form data 
Javascript :: how to use window.alert in javascript 
Javascript :: get output dir from webpack options 
Javascript :: url.createobjecturl 
Javascript :: api dfetch data in reactjs 
Javascript :: Private Class Methods and Accessors in es12 
Javascript :: highlight row javascript 
Javascript :: Subtracting Numbers in Array 
Javascript :: set value 
Javascript :: javascript dropdown options auto-updating 
Javascript :: js plugin for drop down with images 
Javascript :: const isEnabled = !Object.keys(errors).some(x = errors[x]); 
Javascript :: for getting options id using javascript 
Javascript :: splinter wait for input 
Javascript :: Fix Blurry Canvas on Mobile Phones 
Javascript :: getelementbyid without the <script 
Javascript :: npm package al dar una direccion se obtienen las coordenadas longitud y latitud 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =