This is unnecessary, WordPress already provides the fully rendered HTML content in REST responses with the shortcodes already processed and turned into HTML. Inside the object the API responds with is a content
field that has a rendered
sub-field containing what you want. Use that instead of the raw unprocessed version.