ElementAPI: Error's out if entry doesn't have assets These keeps erroring out if any of the entries' do not have any assets in the 'listingPhotos' field. However, IF all entries have at least 1 photo in the 'listingsPhotos' field, it works. 

The Error Message: Trying to get property of non-object 

namespace Craft;

return [
    'endpoints' =&gt; [
        'trucks.json' =&gt; [
            'elementType' =&gt; 'Entry',
            'criteria' =&gt; ['section' =&gt; 'trucks'],
            'paginate' =&gt; false,
            'transformer' =&gt; function(EntryModel $entry) {
                return [
                    'ID' =&gt; $entry-&gt;id,
                    'Year' =&gt; $entry-&gt;year,
                    'Manufacturer' =&gt; $entry-&gt;manufacturer,
                    'Model' =&gt; $entry-&gt;model,
                    'Category' =&gt; (string)$entry-&gt;category[0],
                    'Pics' =&gt; $entry-&gt;listingPhotos[0]-&gt;url,
                ];
            },
        ],
    ]
];
Why don't you just check if there is at least one photo? Something along the lines of

'transformer' =&gt; function(EntryModel $entry) {
    return [
        'ID' =&gt; $entry-&gt;id,
        'Year' =&gt; $entry-&gt;year,
        'Manufacturer' =&gt; $entry-&gt;manufacturer,
        'Model' =&gt; $entry-&gt;model,
        'Category' =&gt; (string)$entry-&gt;category[0],
        'Pics' =&gt; !empty($entry-&gt;listingPhotos) ? $entry-&gt;listingPhotos[0]-&gt;url : null,
    ];
}