Hand-written by Joseph San Nicolas, Roblox Developer
Secret
Constructors
| Name | Description |
| HttpService:GetSecret(key: string):Secret | Returns the Secret stored under the given key in the experience's secret store. Called on HttpService, not on Secret itself - Secret has no direct new() constructor and cannot be created from a plain string in a script. Its content cannot be printed or logged. |
Code Snippet
local HttpService = game:GetService("HttpService")
local apiKey = HttpService:GetSecret("weather_api_key")
local url = apiKey:AddPrefix("https://api.example.com/weather?key=")
local response = HttpService:RequestAsync({
Url = url,
Method = "GET",
})
print(response.StatusCode, response.Body)
Methods
| Name | Parameters | Returns | Description |
| AddPrefix(prefix: string):Secret | prefix: string | Secret | Returns a new Secret formed by prepending the given string to the secret's content, for example prepending "Bearer " to an API key. |
| AddSuffix(suffix: string):Secret | suffix: string | Secret | Returns a new Secret formed by appending the given string to the secret's content, useful for building a URL that contains a key followed by query parameters. |