lundi 5 septembre 2022

Consume Json api format in emberjs

data: [
       
    expiration-date: "2023-06-01T00:00:00"
    name: "Big Fish"
    id: "12932"
    membership-benefits: [{
            available-quantity: 0
            expiration-days: null
            expired-quantity: 0
            is-expired: false
            is-unlimited: false
            name: "Small Fish"
            status: {id: 2, name: "Active"}
            total-earned-quantity: 1
            used-quantity: 1
           }]

in model

@attr('string') name;
@attr('array') membershipBenefits;
@attr('string') expirationDate;

now when i m accessing the values :

console.log(model.name) /// Big Fish ✔️
console.log(model.expirationDate) /// 2023-06-01T00:00:00✔️
console.log(model.membershipBenefits[0].name) /// small Fish ✔️
console.log(model.membershipBenefits[0].status) ///  {id: 2, name: "Active"} ✔️
console.log(model.membershipBenefits[0].isUnlimited) /// undefined ❌
console.log(model.membershipBenefits[0].isExpired) /// undefined ❌

i am getting undefined value when i m accessing hyphenated properties of membershipBenefit array What is the correct way to access these properties??????




Aucun commentaire:

Enregistrer un commentaire