Skip to content

encodeBase64 - Encode a base64 string

encodeBase64 will transform a string into its Base64 encoded value.

Syntax

encodeBase64(value: string): string

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.

{
    path: "/home",
    domain: "coralogix.com",
    full_url: "https://coralogix.com/home"
}

If we want to view to basse64 encode our full_url value, we can use encodeBase64:

create full_url_encoded from encodeBase64(full_url)

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:

create full_url_encoded from full_url.encodeBase64()