Skip to content Skip to sidebar Skip to footer

Json Objects Returns Undefined

I'm returning a JSON object using a 3rd party API. When I print out the variable I get the following: category: { 'sys': { 'id':'44uyBvGjFmsmoU6uqiiSOq', '

Solution 1:

Changed my code to the following. Thanks to Pointy for providing the assistance, much appreciated.

if (o.fields.category)
{
    console.log(o.fields.category.fields.name);

    var category = {};
    category.id = o.fields.category.sys.id;
    category.name = o.fields.category.fields.name;
    category.updatedAt = o.fields.category.sys.updatedAt;
    categories.push(category);
}

record.categories = categories;
record.searchTags = search_tags;
records.push(record);

Post a Comment for "Json Objects Returns Undefined"