How do I convert image to base64 from a URL?

This question was asked on Discord by a user Duane, following is the use-case:

Save the image from a URL to the database as a base64 string.

To save an image into base64, we could use the REST GET on the image URL.

Here’s what the workflow should look like: We’d have to write a JS function to pass the image URL as param to the GET API and then save it to the database.