When Headless CMS Value = null / default value

I’m developing with a headless CMS (Strapi). How do I handle null values or default values?

For example, I’m building a jobs listing website. I have a paragraph element that shows what professional category a job is (e.g. Software Eng, Business Dev, Marketing, etc. etc.). I get this through a content variable:


Well, my CMS isn’t perfect, a bunch of them are empty for professional field. If they’re null, the field turns back to some latin Lorum Ipsum placeholder. I’d like to change what that placeholder text is. I can’t figure out how to do that. Can someone direct me?

Hello, here’s some solution you can try

$value->get('attributes')->get('professional_field', 'DEFAULT_VALUE')
1 Like

Worked great. Is there a youtube video that talks about some of the functions and how to use them? My next challenge is to convert from Enum text (e.g. “BUSINESS_DEVELOPMENT”, “MARKETING”, etc.) to human readable (e.g. “Business Development”).

I also want to do some conditional formatting based on which enum shows up.


I created a video tutorial on how you can create your own function and use it to validate/edit your output text.

In your example, to convert texts like “BUSINESS_DEVELOPMENT” to “Business Development”

You can use something that gpt wrote: :smiley:

    return data.value.replace(/_/g, ' ').toLowerCase().replace(/\b[a-z]/g, function(letter) {
      return letter.toUpperCase();