Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Display image url - help with JS syntax

Topic Labels: API
1715 1
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi there!

Here’s a newbie issue: I’m struggling to get an image url - I’m sure it’s very simple but I’m not very familiar with the syntax.

I’ve tried a few different things but I can’t seem to get the ‘url’ parameter from my image field.

records.forEach(function(record) {
        var $mealInfo = $('<div>');
            $mealInfo.append($('<div>').text(record.get('Photo')));    
            $mealInfo.append($('<h3>').text(record.get('Name')));
            $('#meal').append($mealInfo);
    });

Thanks!!

1 Reply 1

I did find a solution by creating a variable:

var $photoInfo = record.get('Photo');
            $mealInfo.append($('<img>').text($photoInfo[0].url));

I’ll be curious to know if there’s a better way.
Thanks!