Retrieve the data based on the page ID or slug using the Wordpress Rest API

Utilizing the power of the WordPress Rest API as the backend for my project and Nuxt.js to handle the frontend, I am facing a challenge in retrieving data from pages using their ID/Slug since the pages are built with Gutenberg blocks. The issue at hand is that I'm only able to retrieve the first ID and have tried different approaches including mapping out the structure.

  1. Educational Resources/
  2. index.vue
  3. _slug.vue
export default {
  async asyncData ({ app, store, params }) {
    let page = await app.$axios.get(`${store.state.wordpressAPI}/wp/v2/pages?parent=77&_embed`)
    store.commit('setPage', page.data[0])
  },

  computed: {
    page () {
        return this.$store.state.page
    }
  }
}

Answer №1

Can you please provide the section of your HTML code where you display the content? Here is an example:

<div :id="page.title.rendered" exact class="page__content" v-html="page.content.rendered"></div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to selecting the radio button in group2 by clicking on the radio button in group1

Here is my scenario: I have two sets of radio buttons as shown in the code snippet below: <form name="form" method="post" action=""> <label><input type="radio" name="RadioGroup1" value="radio" id="Radio1">Radio 1</label><br> ...

Troubleshooting the pushstate back function in HTML5 and jQuery

In my code, I have implemented an ajax call to load content dynamically. I am now looking to add a deeplinking effect, and after researching, I discovered that only raw coding can achieve this. Here is what I have implemented so far: jQuery("#sw_layered_c ...

Utilizing the bufferGeometry setFromPoints function in conjunction with react-three-fiber

Exploring the functionality of the toLinePath function: const toLinePath = (arrayOfPoints, color = 0x000000) => { const path = new THREE.Path(); const firstPoint = arrayOfPoints[0]; path.moveTo(firstPoint.x, firstPoint.y, firstPoint.z); arrayO ...

Trouble with importing css in Angular webpack due to ui-bootstrap integration

Currently, I am developing an Angular application with Webpack and was looking to incorporate Bootstrap for styling purposes. To achieve this, I first installed 'ui-bootstrap' using npm install angular-ui-bootstrap --save-dev. After installation ...

Showing the number of guilds as an action displayed on the screen

I'm trying to make my bot say "Watching (number of servers it's in) servers!" with this code: const activities_list = [ "with the &help command.", "with the developers console", "with some code", "with JavaScript", client.guilds. ...

What is the best way to incorporate images from JSON responses into an HTML document?

I successfully managed to populate an HTML table with the json responses. However, I'm encountering an issue when it comes to displaying the images associated with the json variables. I'm only able to display the URL links for the images. Below ...

Struggles with arranging elements in the right position

Currently, I am in the process of learning CSS and working on developing a game that involves time and score. In short, here is what I aim to achieve: This is what I have so far: You can find my progress on jsFiddle: http://jsfiddle.net/yZKTE/ CSS: #b ...

JavaScript's dependency injection functionality is ineffective

I am looking to create a function named createCoffee which will take a function argument called knowHow. function createCoffee(knowHow){ var x=new knowHow(coffee,beans,milk,sugar); knowHow.create(); } This will allow me to use different knowHow funct ...

Obtaining an image from a URL, saving it, and then animating it? That definitely

Looking to create a dynamic animation with images that update every 15 minutes from the following URL: How should I go about storing and looping through the most recent 24 images for the animation? Is using a MySQL database the best option or are there o ...

JavaScript escape sequences are used to represent characters that are

Is there a way to pass a variable to another function in this scenario? I am inserting a textarea using JavaScript with single quotes, but when the function myFunction(abc123) is called, it appears like this, whereas it should look like myFunction('ab ...

The tooltip in chart.js stubbornly holds onto past data even after it's been

Utilizing chart.js, I have implemented a feature where a tooltip displays when a user hovers over the chart successfully. However, I encountered an issue. I added an option for users to un-check data-points, which works correctly. But now, the tooltip fun ...

Navigation buttons that move the user either up or down the page

I am a beginner in programming and I wanted to create two buttons for my webpage. One button should appear when the page is scrolled more than 300px and take the user to the top, while the other button should be displayed immediately and scroll the user to ...

Capture an image of a webpage and print it out

I am currently in the process of designing a web page and one of the key features I need is a button that allows users to print a selected area. After conducting several searches, I came across html2canvas as a potential solution. I proceeded to install it ...

I am interested in creating an input range slider using React and TypeScript

This code was used to create a slider functionality import { mainModule } from 'process'; import React, { useState } from 'react'; import styled from 'styled-components'; const DragScaleBar = () => { const [value, setV ...

The inconsistency of Selenium's StaleElementReferenceException error and the variability of pageload completion codes is causing issues with clicking on elements

Big shoutout to the amazing stackoverflow community for always providing assistance. Lately, I've been grappling with the frustrating "StaleElementReferenceException" issue and haven't found a universal solution yet. Some helpful members have rec ...

Next.js Refresh Screen

Is there a way to refresh my client's web page from the server at a specific time? I need the client's page to be refreshed at 12pm, and although I'm using a scheduler, it doesn't seem to be automatically refreshing the web page on the ...

Watching the $scope variable using $watch will result in triggering even when ng-if directive is used, displaying

Encountering an unusual behavior in AngularJS that may appear to be a bug, but there could be a logical explanation. A certain value is being passed to a directive as an attribute. Within this directive, the parameter is being watched using $scope.$watch. ...

How to connect site pages in WordPress using Vue.js

I'm currently in the process of revamping a website using the vuejs framework and I've started off with this boilerplate as my foundation. My experience with vuejs is very fresh, just 3 days old, so I'm still trying to understand how to crea ...

Using MIPS Assembly Language: Displaying Register Content on Screen

I'm working on replicating a simple form of debugging in MIPS similar to javascript. I am wondering how I can achieve the equivalent of this ($t0 represents a javascript variable here): console.log($t0); In simpler terms, I am looking for the metho ...

What is the best way to verify changing input fields in vue.js?

Validation of input fields using vuelidate is essential. The input field in question is dynamic, as the value is populated dynamically with jsonData through the use of v-model. The objective: Upon blur, the goal is to display an error if there is one; ho ...