0

I need to get a particular value from the JSON and store it in the variable in LWC is there any way I can do it:

asd==[
   {
      "ABC":"ytyffy98948",
      "custui":"009686758jbnvnvm",
      "CAR__c":"YUI",
      "RAF__C":f,
      "FAN__C":"78tu8u"
      
      
   }
]
const sdfr== asd.FAN__C;

I am getting the value in sdfr as undefined. the actual value in JSON is 78tu8u

kindly help me out for this.

1

Your code has a syntax error in it. You need to use a single = sign for the assignment.

asd=[
   {
      "ABC":"ytyffy98948",
      "custui":"009686758jbnvnvm",
      "CAR__c":"YUI",
      "RAF__C":"f",
      "FAN__C":"78tu8u"  
   }
]

Also asd is an array, not an object. So you need to access it like below.

const sdfr = asd[0].FAN__C;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.