encodeBase64 - Encode a base64 string
encodeBase64
will transform a string into its Base64 encoded value.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
value | string | true | The string to be base64 encoded |
Example - Encoding URLs into Base64
It's common to send data that contains special or reserved characters, like URLs, in Base64 encoded format, to ensure there are no parsing issues.
If we want to view to basse64 encode our full_url
value, we can use encodeBase64
:
The resulting document will look like this:
{
path: "/home",
domain: "coralogix.com",
full_url_encoded: "aHR0cHM6Ly9jb3JhbG9naXguY29tL2hvbWU=",
full_url: "https://coralogix.com/home"
}
An alternative way to write this function is as follows:
Theme
Light