Nuxt has the ability to display the object itself, however, it cannot render its

I am using a directus API to fetch data, which is returned in an array of objects. I can render the array or an object from it, but not when trying to access a property of the object

 <template>
    <div class="grid grid-cols-2 gap-6 mt-6">
        <div class="flex justify-center items-center">
            <div class="flex flex-col items-stretch w-full">
            <img loading="lazy" src="@/assets/images/berita-1.png" class="aspect-[1.7] object-fit-cover object-center max-w-[580] overflow-hidden max-w-full" />
            <h3 class="text-black text-justify text-l font-bold py-4">
                <a href="#">{{ Berita[0].Title }}</a>
            </h3>
            <p class="line-clamp-2 text-justify text-black">
                Departemen Teknik Industri Fakultas Teknik Universitas Hasanuddin menggelar
                International Guest Lecturer yang dibawakan oleh Profesor yang juga sebagai 
                Head Of Laboratory Ergonomics for All Ages and Abilities dari Kyushu 
                University Prof. Satoshi Muraki, Ph.D., CPE. International Guest Lecturer 
                dilaksanakan pada Senin 9, Oktober 2023 dan dilaksanakan secara daring dan 
                luring di Gedung CSA LT 1 Fakultas Teknik Universitas Hasanuddin.
            </p>
            </div>
        </div>
    </div>
</template>

Here is what's inside Berita (an array of objects)

[
    {
        "id": "8f790756-54e2-43fe-8a23-5aa49277a9af",
        "sort": null,
        "user_created": "a4655746-7c37-4b7d-9739-8e0d85d6503a",
        "date_created": "2023-11-09T01:11:13.228Z",
        "Title": "Fakultas Teknik Universitas Hasanuddin Terima Kunjungan Benchmarking Universitas Halu Oleo.",
        "Slug": "fakultas-teknik-universitas-hasanuddin-terima-kunjungan-benchmarking-universitas-halu-oleo",
        "Konten": "<p>Fakultas Teknik Universitas Hasanuddin menerima kunjungan dari Universitas Halu Oleo. Kunjungan ini dilaksanakan dalam rangka Benchmarking Program Studi Magister Teknik Sipil dan Program Studi Pendidikan Profesi Insinyur. Benchmarking tersebut dilaksanakan pada Senin, 6 November 2023 di Ruang Rapat Lantai 3 Gedung CoT Fakultas Teknik Universitas Hasanuddin.&nbsp;</p>\n...
    },
    {
        "id": "30d4a1bf-fba0-46ae-8862-2f5b5bb2d1f7",
        "sort": null,
        ...
    },
    {...}
]

Answer №1

There are only a handful of scenarios that can lead to this issue, most of which can be attributed to the following reasons:

  1. fetch call returns a Promise, initially set to undefined, requiring us to handle it appropriately:
  <a href="#">{{ Berita?.[0].Title }}</a>
  1. In rare cases, using RefLike may cause vue to fail in resolving the variable; adding .value as a suffix resolves this issue:
  <a href="#">{{ Berita.value?.[0].Title }}</a>

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

Issue with Angular 7: In a ReactiveForm, mat-select does not allow setting a default option without using ngModel

I have a Angular 7 app where I am implementing some reactive forms. The initialization of my reactive form looks like this: private initFormConfig() { return this.formBuilder.group({ modeTransfert: [''], modeChiffrement: [' ...

Switch Between Different Components in VueJS

I am currently working on a VueJS project to create a navigation bar with toggleable drop-down menus. While I can successfully toggle individual menus, I am struggling to figure out how to handle multiple drop-down menus so that when one menu is opened, th ...

It's incredibly frustrating when the Facebook like button is nowhere to be found

Currently, I am in the process of developing a website for a local bakery and have decided to incorporate a Facebook like button on the homepage. After visiting developers.facebook, I proceeded to copy and paste the code provided. It appears that there use ...

"Can you explain the method by which reveal.js adjusts the size of

I have been exploring the resizing behavior of elements in reveal.js and trying to understand how they dynamically adjust. If you resize the page height, you can observe that the elements shrink up to a certain extent along with the page. However, when in ...

Tips for dynamically sending data without explicitly stating the name:

Looking to create a JSON structure with name and value pairs such as name:"john". Check out the code snippet below: var allFields = []; var inputs = document.getElementsByTagName('input'); for(var i=0; i<inputs.length;i++){ name = in ...

Add a npm module without type definitions

I am currently utilizing Typescript version 2.1 and facing an issue with installing an npm package called 'reactable' that lacks typings. When attempting to import the package using import * as Reactable from 'reactable', Typescript di ...

Unexpected issue on AngularJS application

Encountering issues with incorporating a controller into my page - each time I add it to a DOM element, an error is thrown. Here's the structure of my HTML page: <html data-ng-app="sportsStore"> <head> <title>Sports Sto ...

Exploring the power of nested loops within an AJAX call in Angular

I have been attempting to iterate through a variable, search for IDs, and then make an ajax call to retrieve the detailed content of the different IDs. In the Success function, I am trying to loop through the received content and extract the emails. While ...

Separating the logic of identical schemas and implementing multi-tenancy in Node.js using Mongoose

In the system I am developing, there are two key requirements: Each client needs to be completely isolated from one another Clients can have multiple subsidiaries which they should be able to switch between without needing to re-authenticate, while ensuri ...

The functionality of Javascript Regular Expressions is not performing as expected

I am currently facing an issue with email validation in JavaScript as it doesn't seem to be working properly. PROBLEM: Even when entering a VALID email address, the alert still shows that my address is faulty... What could I possibly be missing he ...

What is the process for importing a jquery plugin like turnjs into a React component?

After searching through countless posts on stackoverflow, it seems like there is no solution to my problem yet. So... I would like to integrate the following: into my react COMPONENT. -I attempted using the script tag in the html file, but react does no ...

Tips for Avoiding Database Overflow Due to Excessive AJAX Spam Requests

Let's consider a simple scenario: A create album button is used to input album data into the database. I disable the button while the request is being processed, then re-enable it upon completion. Once the processing is finished, ...

Error: Uncaught ReferenceError - 'channel' has not been defined

I'm currently working on a Discord bot that is designed to handle tickets and I'm facing an issue with sending messages in the newly created channel I attempted using .then, but for some reason it's not functioning as expected and I'm ...

Does tns preview offer support for Vuex?

Since integrating Vuex into my NativeScript-Vue mobile app, I have encountered an issue where tns preview fails to resolve modules that rely on Vuex. Interestingly, the application functions properly when using tns run or tns build. This problem is prese ...

"Customize the number of items displayed per page with Bootstrap Vue's perPage

I am currently working on a Vue project which you can view on codesandbox and utilizing bootstrap-vue. Within the project, there are multiple columns containing cards along with pagination: <template> <b-container> <b-row :cu ...

Gain access to a composable data using the defineDefault method in Vue 3 with Vuetify

On numerous pages, I have a component with default props. I am looking to access a composable data (useTheme from vuetify) within the "withDefaults". <script setup lang="ts"> import { ref } from 'vue' import { useTheme } from &apo ...

Type of Data for Material UI's Selection Component

In my code, I am utilizing Material UI's Select component, which functions as a drop-down menu. Here is an example of how I am using it: const [criteria, setCriteria] = useState(''); ... let ShowUsers = () => { console.log('Wor ...

Experience the power of TypeScript in a serverless environment as you transform your code from

I have some JavaScript code that needs to be converted to TypeScript. Currently, I have two files: API_Responses.js const Responses = { _200(data = {}) { return { statusCode: 200, body: JSON.stringify(data), }; } }; module.export ...

Modifying attributes for individual components in Vue.js classes

Recently, I integrated a reusable component called "LightBox" into my website, which displays images in higher resolution. The LightBox functionality is linked to each element having a thumbnail. However, I encountered an issue. There are multiple elements ...

Troubleshooting issue with TypeScript: Union types not functioning correctly when mapping object values

When it comes to mapping object values with all primitive types, the process is quite straightforward: type ObjectOf<T> = { [k: string]: T }; type MapObj<Obj extends ObjectOf<any>> = { [K in keyof Obj]: Obj[K] extends string ? Obj[K] : ...