Get PDF file from Assets Folder - Element API I have a PDF folder within assets and having trouble accessing the file path once chosen by the user. 

To get something like an image from assets within a matrix I do something like this which works: 

'image' =&gt; $block-&gt;image[0]-&gt;url,


I have tried similar code however it seems url is not available? 

'downloadablePDF' =&gt; $block-&gt;downloadablePdf[0]


I need to return the URL so that I can pass the URL to a React Component to make the pdf downloadable. 

Here is my full code to fetch data from a matrix block: 

function articles($array) {
    $articles = [];
    foreach ($array as $block) {
        switch ($block-&gt;type-&gt;handle) {
            case 'article':
                $articles[] = [
                    'heading' =&gt; (string) $block-&gt;heading,
                    'subheading' =&gt; $block-&gt;subheading,
                    'text' =&gt; (string) $block-&gt;text,
                    'backgroundImage' =&gt; (isset($block-&gt;backgroundImage)) ? $block-&gt;backgroundImage[0]-&gt;url : '',
                    'downloadablePDF' =&gt; $block-&gt;downloadablePdf[0],
                    'videoUrl' =&gt; (isset($block-&gt;videoUrl)) ? $block-&gt;videoUrl : '',
                    'linkUrl' =&gt; (isset($block-&gt;linkUrl)) ? $block-&gt;linkUrl : '',
                    'size' =&gt; (isset($block-&gt;size)) ? $block-&gt;size-&gt;value : '',
                    'style' =&gt; (isset($block-&gt;style)) ? $block-&gt;style-&gt;value : '',
                    'verticalTextAlignment' =&gt; (isset($block-&gt;verticalTextAlignment)) ? $block-&gt;verticalTextAlignment-&gt;value : '',
                ];
            break;
        }
    }
    return $articles;
}
You have to check if your matrix element has a block or not with the code $block-&gt;downloadablePdf[0]-&gt;url you'll access the first element in your matrix but when there is no it will throw an error.

'downloadablePDF' =&gt; $block-&gt;downloadablePdf[0]? $block-&gt;downloadablePdf[0]-&gt;getUlr() : ''


will check if there is an asset and return the url or an empty string if there is no asset