Display information from a JSON file using Vue.js

Hello, I am currently attempting to display data from a JSON file using Vue.js. Below is my Vue file:

<template>
    <div>
        <div class="card">
            <div class="card-header">
                  <h4 class="card-title">Customer Infos</h4>
            </div>      
            <div class="card-content">
             {{site}}
            </div>      
        </div>
    </div>
</template>
<script>
    export default {
        props: ['site'],
        mounted () {
            console.dir(this.site)
        }
    }
</script>
<style>
</style>

Here is the resulting data:

{"id":274292982,"site_id":"2512016716"}}

I am aiming to only display the site_id from the data.

I have already attempted the following:

 {{site.site_id}}

However, this has not been successful. Thank you for your help.

Answer №1

computed: {
webpage() {
    return JSON.parse(this.site);
}

subsequent to

{{ webpage.site_id }}

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

In MongoDB, rather than storing hashed passwords, it stores a "Promise" object

I've implemented bcrypt for hashing passwords and MongoDB for my database storage. Check out the code snippet below: export default function buildMakeUser({pwdHasher}) { return function makeUser({ username, email, passwor ...

Issue with loading controllers in route files [Node.js]

I've encountered an issue while trying to include a user controller into my routes for a node js app. Everything was working fine until suddenly it started throwing an error message. I've thoroughly checked the code for any potential issues but s ...

Unable to display the attributes of an object using console.log

I am attempting to log the properties of an object in TypeScript, but I am encountering issues. setTitleAndBody(result: { title: String; body: String; }) { console.log(result) console.log(result.title) } What's interesting is that if I only l ...

Changing from a vertical to horizontal menu as the parent div is resized

I am looking for a solution to create a CSS effect or Javascript code that will hide a menu inside a div when the browser window or parent div is resized. I want to display another div with the same menu in horizontal orientation when the first one is hidd ...

Tips for converting regular strings into JSON format

I need to retrieve specific variables and convert them into JSON format. These variables are saved in columns, for example: first_name = request.values['name'] person_age = request.values['age'] This currently returns something like: ...

What are the benefits of storing multiple rows within a single Cassandra row?

I came across a fascinating approach to storing nested dynamic documents in Cassandra. The presentation I found suggests creating only a few rows and storing multiple JSON objects in each row. You can check it out here: The concept of naming columns based ...

Is it possible to pass multiple IDs into document.getElementById?

I am working on a form that contains 45 dropdown lists and currently, I am using the following code for validation. Is there a way to modify this code so that I can use a single function to validate all 45 dropdown lists? Below is the Function: function ...

AJAX list refresh, fetch additional items and tally

Looking for a solution to update the values of listUsernames and numUsernames after adding an item? Check out this scenario: <ul id='usernameList'> <li class='username'>John</li> <li class='username&apo ...

Creating a hierarchical tree in JavaScript and generating nested UL/LI output with ExpressJS

I have a piece of code from another request that is functioning properly. It creates a hierarchical tree with deep levels using JSON. However, I require the output to be in the form of an HTML UL/LI nested structure or a select menu for parent and child el ...

Manipulating specific elements within a MongoDB document's array using index values in a Node.js environment

Is there a way to increase the value of a specific element in an array within a MongoDB document using Meteor or nodeJS? For example, consider the following document: { "_id" : "4tP6ewe4Z5kwYA3Je", "name" : "chutia", "address" : "shonir akhra ...

Angular findIndex troubleshooting: solutions and tips

INFORMATION = { code: 'no1', name: 'Room 1', room: { id: 'num1', class: 'school 1' } }; DATABASE = [{ code: 'no1', name: 'Room 1', room: { id: 'num1', ...

Connect various models together, or create synchronized computed properties

At times, the model abstraction may fall short, leading to the necessity of synchronizing two different models. For instance, I have two lists linked by an angular sortable, which requires a model structure like this: left = [{name:"one"}, {name:"two"}]; ...

When employing Flatlist, an issue arises where the image fails to appear on the screen, accompanied by an error message stating "value for uri cannot be cast from Double to String."

I'm facing an issue with displaying images in my flatlist. The error message I receive is "Error while updating property 'src' of a view managed by : RTCImageView." Can anyone help me identify what might be causing this problem in my code? ...

The infinite loop issue arises when the useEffect is utilizing the useNavigate hook

As I integrate the useNavigate hook within React to guide users to a specific page post-login, an unexpected infinite loop arises. Most sources online recommend utilizing the useNavigate hook inside a useEffect block; however, this method triggers a Warnin ...

Using Python to load a JSON file into a JSON field in SQLAlchemy

I'm a Python novice and it seems like there should be a straightforward solution to my problem that I must be overlooking. Many of the solutions on StackOverflow appear overly complicated for what I am trying to accomplish. I have several hundred tex ...

Retrieve the information from a website and display it on the current webpage using an ajax request

Is there a way to insert parsed HTML content into my webpage using just a link from another page? I'm attempting to use an AJAX call, but I keep receiving an error. Below is the code I've written, and the browser doesn't seem to be the issue ...

Java/Groovy: Transforming XML into an Array of Objects

Here is an example of the XML structure: <jobs> <no>2</no> <job> <status>Completed</status> </job> <job> <status>In Progress</status> </job> </jobs> Attempting to p ...

There seems to be an issue with the babel `--watch` feature, as it is not properly updating the es6 folder

I am in the process of developing a basic component library and I want it to be automatically compiled every time I make any changes to my files. Here is the command I am currently using: "watch": "babel components/ --out-dir dist --copy-files --ignore t ...

develop custom button in vue-good-table-next

I am attempting to set up a datatable using vue-good-table-next and Vue 3 in Laravel 9. I have successfully populated all the data using Axios. However, I am facing an issue where I need to implement custom buttons for editing and removing entries. Despi ...

Unable to access properties of an unknown item (reading 'remove')

Can you provide guidance on how to remove the top-level parent element of a div? I've been attempting to delete the main parent element of a specific div. element.innerHTML = ` <div class="postIt-item"> <div class="postIt-item-btn ...