简体   繁体   中英

Issues creating a new JSON object in Node.js

Sorry I am new to programming, could anyone help with this please. I can log the profile object, a JSON object with 10 items, but I cant log the vehQ, which should contain only 3. Have I written this incorrectly?

        let profile = await this.getProfileDetails(params)
        console.log(profile)
            var vehQ = {}
            if (profile ) {

                vehQ["profileID"] = profile[0].profileID
                vehQ["regNumber"] = profile[0].regNumber
                vehQ["compatibility"] = profile[0].compatibility
                console.log(vehQ)

您可能将 JSON 作为字符串接收,您需要将其解析为 JS 对象。

const parsedProfile = JSON.parse(profile);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM