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

Toggle the status of active to inactive instantaneously with the click of a

Incorporating DataTables with ajax using PHP CodeIgniter Framework has presented me with a challenge. I am struggling to toggle between Active and Inactive buttons seamlessly. My desired outcome: When the Active button is clicked, it should transition ...

What are some javascript libraries that can be used to develop a mobile image gallery for both Android and iPhone

I currently have the touch gallery system in place, but unfortunately it isn't functioning properly on Android devices. ...

Please enter a numerical value into the input field in a JavaScript form

<script> function loop() { var input = document.getElementById('inputId').value; for (var i = 0; i < input; i++) { var result = document.getElementById('outputDiv').innerHTML ...

Displaying or concealing an HTML element based on a JavaScript XHR request function

I have a single HTML element that I need to display and hide using jQuery within a pure JavaScript XHR request method. Currently, the element always remains visible without hiding when the request is complete or successful. On error, I would like it to be ...

How to send props from a Vue.js component tag in an HTML file

I'm facing an issue with passing props from the HTML to the JavaScript code and then down to a Vue component. Here's a snippet of my index.html file: <div id="js-group-discounts"> <div class="form-group required"> <datepick ...

Guide to building a react-redux application with a Node server as the backend

Hey there! I'm looking to build a react-redux app with a node server as the backend. Is it feasible for the node server to serve the react-redux app instead of having react-redux run on one port and node on another? Any suggestions on how to kick thi ...

Extract data from a JSON-encoded array using JavaScript

I sent a JSON encoded array to JavaScript. Now I want to access that array to retrieve the different elements. When I print it out using console.log(), I see this array: array(1) { [16]=> array(2) { [3488]=> array(1) { [0]=> ...

"Utilizing an exported constant from a TypeScript file in a JavaScript file: A step-by-step guide

I am facing an issue when trying to import a constant from a TypeScript file into a JavaScript file. I keep encountering the error Unexpected token, expected ,. This is how the constant looks in the ts file: export const articleQuery = (slug: string, cate ...

Is it possible to synchronize functions in node.js with postgresql?

I’m facing some challenges in managing asynchronous functions. Here is the code snippet that's causing the issue: var query = client.query("select * from usuario"); query.on('row', function(user) { var queryInterest = client. ...

Is it possible to protect assets aside from JavaScript in Nodewebkit?

After coming across a post about securing the source code in a node-webkit desktop application on Stack Overflow, I began contemplating ways to safeguard my font files. Would using a snapshot approach, similar to the one mentioned in the post, be a viable ...

Having trouble adding state values to an object

I have a specific state set up in my class: this.state = { inputValue: "", todos: [] } My issue lies within an arrow function where I am attempting to use setState to transfer the value of inputValue into todos. this.setState({ inputValue: & ...

Error: Unexpected end of input detected (Likely due to a missing closing brace)

I've been struggling with this bug for the past two days, and it's driving me crazy. I have a feeling that I missed a brace somewhere in my script, but despite running various tests, I can't seem to pinpoint the glitch. Hopefully, your eyes ...

React app experiencing inconsistent loading of Google Translate script

In my React application, I have integrated the Google Translate script to enable translation functionality. However, I am facing an issue where the translator dropdown does not consistently appear on every page visit. While it sometimes loads properly, oth ...

What is the best way to hide a custom contextmenu in AngularJs?

I created a custom contextmenu directive using AngularJs. However, I am facing an issue where the menu is supposed to close when I click anywhere on the page except for the custom menu itself. Although I have added a click function to the document to achie ...

Middleware in Express can be executed more than once

I am encountering a frustrating issue where my middlewares are being called multiple times without explanation. Despite having written short and simple code while learning Express and Node, I cannot pinpoint the reason for this behavior. I find it confusin ...

Issue with HighCharts Series Data Points Not Being Added

I am currently facing a major challenge in dynamically changing data for highcharts based on date. To provide context for my project, it involves logging system data with timestamps. I have implemented a date and time picker to specify the start and end da ...

Freeze your browser with an Ajax request to a specific URL

There is a function in my view that transfers a value from a text box to a table on the page. This function updates the URL and calls another function called update_verified_phone(). The update_verified_phone() function uses a model called user_info_model( ...

In Vue Js, the function createUserWithEmailAndPassword does not exist within _firebase_config__WEBPACK_IMPORTED_MODULE_3__.default

My createUserWithEmailAndPassword function seems to be malfunctioning. Here is the code snippet I am using - config.js import firebase from 'firebase/app' import 'firebase/firestore' import 'firebase/auth' const firebaseCon ...

The data set in a setTimeout is not causing the Angular4 view to update as expected

I am currently working on updating a progress bar while importing data. To achieve this, I have implemented a delay of one second for each record during the import process. Although this may not be the most efficient method, it serves its purpose since thi ...

The div swiftly clicks and moves beyond the screen with animated motion

Here is a code snippet that I am working with: $(document).ready(function(){ $(".subscriptions").click(function (){ if($(".pollSlider").css("margin-right") == "-200px"){ $('.pollSlider').animate({"margin-right": '+ ...