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.

Update admin components from hooks

default discord avatar
kulczy2 years ago
2

hi there, i call external api from the 'beforeChange' hook, and i would like to update admin panel to display current status of this operation, something like "syncing with the API", "syncing complete", somewhere in header or sidebar. Could anyone give any tips on how to go about this?

  • default discord avatar
    notchr2 years ago
    @774566809797394463

    Morning! You could start by creating a custom Admin Component. This will allow you to add it somewhere that makes sense. The component would make a request to the external data and report status (loading indicator?). This is how I see it working, but others might have better solutions.

  • default discord avatar
    jessrynkarlast year
    @774566809797394463

    for a slightly different approach you can checkout this

    syncDocs

    button:

    https://github.com/payloadcms/website-cms/blob/main/src/payload.config.ts#L156

    It adds a component to

    afterNavLinks

    that hits a custom endpoint to fetch data from GitHub.

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.