Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Transform Text

default discord avatar
steprob2 years ago
4

I am at a crossroads. The API returns me data in uppercase and lowercase, is there any way that the API returns me the data only in uppercase? It could be done from the Frontend, but the component I'm working on for some strange reason does not allow me to transform them to uppercase.

  • discord user avatar
    jarrod_not_jared
    2 years ago

    You could use a beforeChange hook to uppercase the field before saving if you wanted to prevent future misalignments. You would need to write a small script to update the existing ones (ez to do).



    Or you could use a beforeRead hook that transforms the text before it’s returned.



    I would likely go with option 1 bc the compute would only need to be done on write, and never on read.

  • default discord avatar
    steprob2 years ago

    I understand, would you be so kind to provide an example of option 1 please

  • discord user avatar
    jarrod_not_jared
    2 years ago

    Which part are you unsure of?

  • default discord avatar
    steprob2 years ago

    of how the beforeChange hook should be implemented

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.