Guide on how to fetch an image using a link within an object

I have been utilizing Vue JS to develop a web application.

While converting the object into JSON, I've noticed that the link used to retrieve the image only appears as a string due to the JSON conversion process.

Is there a way for the link to properly display the image? Could it be an issue with my JSON conversion method?

const app = Vue.createApp({
  data() {
    return {
      baby: [

        {
          id: "botamon",
          name: "Botamon",
          stage: "Baby",
          type: "Data",
          digivolution: ["Koromon"],
          image: "https://www.grindosaur.com/img/games/digimon-world/digimon/12-botamon.jpg"
        },

        {
          id: "poyomon",
          name: "Poyomon",
          stage: "Baby",
          type: "Data",
          digivolution: ["tokomon"],
          image: "https://www.grindosaur.com/img/games/digimon-world/digimon/86-poyomon.jpg"
        },

        {
          id: "punimon",
          name: "Punimon",
          stage: "Baby",
          type: "Data",
          digivolution: ["tsunomon"],
          image: "https://www.grindosaur.com/img/games/digimon-world/digimon/88-punimon.jpg"
        },

        {
          id: "yuramon",
          name: "Yuramon",
          stage: "Baby",
          type: "Data",
          digivolution: ["tanemon"],
          image: "https://www.grindosaur.com/img/games/digimon-world/digimon/123-yuramon.jpg"
        },
      ],
    }
  },

  methods: {
    blueEgg() {
      JSON.parse(JSON.stringify(intraining[0].image))

    },
  },

})
app.mount('#app')
:root {
  --white-color: #ffffff;
  --baby-yellow: #FFF141;
  --training-blue: #19E0FA;
  --rookie-gold: #AD9B11;
  --champion-pink: #FA198C;
  --ultimate-violet: #AD095D;
}

#yellow-background {
  background-color: var(--baby-yellow);
  height: 50vw;
}

#yellow-background h1 {
  font-size: 15px;
  text-align: center;
  padding: 0.3em;
}
<div id="app">

  <div class="container" id="yellow-background">
    <h1>In-training Stage</h1>
    <div class="image">{{baby[2].image}}</div>
  </div>

</div>

<script src="https://unpkg.com/vue@next"></script>

Answer №1

If you're looking to display content from a JSON object using Vue, you can utilize the following code snippet:

<div class="container" id="yellow-background">
  <h1>In-training Stage</h1>
  <img :src="baby[2].image" alt="">
</div>

For more information on how to select nested "src" values in a JSON object with Vue, check out this helpful resource: Guide on selecting nested "src" in JSON objects with Vue

Answer №2

Kissu pointed out the solution:

Here is the HTML code:

 <div class="container" id="yellow-background">
   <h1>In-training Stage</h1>
   <img :src="baby[2].image" alt="">
 </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

Personalized parallax design

I am in the process of developing my own custom parallax plugin to allow me to control the direction in which items transition off the screen. However, I am currently facing a challenge in ensuring that regardless of how a user scrolls or the size of the w ...

Adjusting the size of a dynamically generated rectangle using DrawingManager

I am currently working on a web application using Azure Maps along with the DrawingManager library. My goal is to allow users to save a drawn rectangle and potentially edit it by resizing later on. The strange thing is that while resizing rectangles works ...

Creating buffer geometries for spheres using Three.js

Currently, I am working on a three.js project that involves displaying numerous spherical objects. To achieve this quickly, I decided to utilize buffergeometry. Upon researching, I came across a helpful post here, where I learned that I could transform nor ...

Transferring information between components and pages within Next.js involves the passing of data

I currently have an index page set up like this: getServerSideProps(){ //Making two API calls here api1() api2() return{ props:{data:gotDataApi1, data2:gotDataApi2} } } The data retrieved from these APIs is then passed to a component within the index pag ...

What is the method for retrieving Polymer data that has been bound and incorporating it into a script?

My current setup involves utilizing the <firebase-document> element to retrieve data from Firebase. The data is then bound to {{poster}}, which allows me to access details of the poster object using its keys. For instance, {{poster.name}} displays th ...

Issues with compiling Vuetify SASS in Nuxt for incorrect output

I am trying to integrate Vuetify with Nuxt using a Plugin but I am encountering the following issue: https://i.sstatic.net/KZbCN.png Error Message: ERROR in ./node_modules/vuetify/src/components/VProgressLinear/VProgressLinear.sass ...

Remove the container once all of its children have been dismissed

Is it possible to automatically remove the parent container when all of its children elements have been removed? Each child element has a dismissal option that, when clicked, removes the element. I am using backbone.js for this project and would like a so ...

Safari browser cutting off POST parameters prematurely

I am encountering an issue where my code works perfectly on all browsers except Safari 6.1.2 on Mac OS Lion. Below is the AJAX post code that I am using - $.ajax({ type: 'POST', dataType: 'text/html', url:"/MyProxy.php ...

Is there a backend-exclusive solution for scheduling periodic function calls without using JavaScript?

In the JavaScript file that I have included in the main .cshtml page of my ASP.NET MVC application, the following code can be found: var ajax_call = function () { $.ajax({ type: "GET", cache: false, url: "/Session/Index/", ...

Executing an angular directive within the template of another javascript framework

I am currently in the process of converting an angular application to ember.js as a way to expand my skill set. Within our project, we have a custom angular module that was created through a directive. Due to the time it will take to port that component o ...

Issues with JQuery Ajax file upload functionality in the client's browser causing upload problems

Seeking to integrate a profile picture upload feature with Ajax and JQuery I've been successful in uploading profile pictures to my database on various machines and mobile devices, including Chrome, Edge, Firefox, Safari, and Vivaldi. However, my cl ...

Validation using Java Script and outputting results

I'm looking for a way to validate an HTML form using Javascript. If any fields are left blank, I want to display an error message above the form instead of inside each field. Can anyone provide me with code that achieves this? Here is my current form ...

After refreshing the page, the JQuery radio button will still be selected

In my form, a radio button triggers an additional text field based on user selection. To achieve this functionality, I am using the following jQuery script: $(document).ready(function(){ $('input:radio[name="accountType"]').change(function() ...

Including Vuetify in my project has triggered a SecurityError, specifically relating to the CSSStyleSheet.cssRules getter being restricted from accessing cross-origin stylesheets

Looking to create a Vue application that opens a CKEditor component in a separate window, I managed to do so following the method outlined in this helpful post. I have even set up a Codesandbox demonstration to showcase the functioning example. However, u ...

How can I determine the caret position within a contentEditable div?

I am currently developing a text editor feature for my blogging platform. I am looking to incorporate a small toolbox that allows users to edit their blog posts by selecting text and applying various styles such as bold, italic, and color changes. Addition ...

What is the best way to combine data from two rows into one row?

Can someone help me with merging 2 sets of Line data into a single row for each entry? For example, the 'Green Bay Packers @ Chicago Bears' row should display '+3.5000 and -3.5000', while 'Atlanta @ Minnesota' should show &apo ...

What are some effective methods for selectively handling batches of 5-20k document inputs when adding them to a collection containing up to one million documents using MongoDB and Mongoose?

My MMO census and character stats tracking application receives input batches containing up to 5-20k documents per user, which need to be aggregated into the database. I have specific criteria to determine whether a document from the input already exists i ...

Using NodeJS to extract information from Opendata JSON files

I'm currently working on a project that involves fetching JSON data from an Open Dataset using NodeJS and passing it to angular. The challenge I'm facing is that I'm receiving a JSON file instead of a JSON object, which makes it difficult to ...

Localhost being injected into the pathname by Axios

I am trying to implement an axios request using their official documentation. Here is my code snippet: const REFERRAL_API_URL= "https://referrals.gen.com" export function createReferral() { axios({ data: {}, headers: { 'Content-Type ...

Executing a JavaScript Function in the Background using Cordova

Despite the numerous questions and plugins available on this topic, finding a solution has proven to be elusive for me. The most highly recommended plugin for this issue can be found here. My goal is to run MyService in the background, subscribe to the ON ...