Home > OS >  Value from array is not printing in html
Value from array is not printing in html

Time:10-08

I need to display a response from api using interpolation.

I have tried:-

response['data'][0].value// can console this value here


this.variable = response;


<p>{{  variable['data'][0].value }}</p>

response will be :-

{
  "data": [
    {
        "value": "abc",
    },
    {
        "value": "efg",

    },
   ]
}

CodePudding user response:

try doing this.

const response = {
  "data": [{
      "value": "abc",
    },
    {
      "value": "efg",

    },
  ]
}

const value = response.data[0].value;
const value_2 = response['data'][0]['value'];
console.log(value);
console.log(value_2);

  • Related