Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
What causes the failure to display the posts author name from the WordPress API in a Handlebars view?

I am working on making a blog using WordPress as a headless CMS and Express Handlebars for the views.

In the controller I have:

var axios = require('axios');

/* GET home page data */
exports.getHomepageData = async (req, res, next) => {
  try {
    let [postCaregoriesData, postData] =  await Promise.all([
        axios.get(`${base_url}/categories`),
        axios.get(`${base_url}/posts?_embed`),
    ]);
  
    const posts = postData.data;
    const categories = postCaregoriesData.data;

    posts.forEach(function(post){
        console.log(post._embedded.author[0].name);
    });
  
    res.render('index',
    {
      layout: 'layout',
      pageTitle: 'All posts',
      categories: categories,
      posts: posts,
  
     });
  } catch (error) {
    res.status(500).json(error);
  }
};

This line displays the autor's name in the terminal:

 posts.forEach(function(post){
    console.log(post._embedded.author[0].name);
 });

In the view however, where I sucesfully display the post title, I use this to dysplay the post author name:

{{#each posts}}
   {{this._embedded.author[0].name}}
{{/each}}

This fails with the error:

Expecting 'ID', got 'INVALID'

What is missing from the code?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda