问题
I am writing a firebase function.
And in there, I need a default value.
And since I set up a Remote Config in Firebase, I try to use it inside my firebase function (to have one source of truth as for the default-values)
Using the following code to retrieve a remoteConfig-parameter, how can you convert it to a typescript number ?
const remoteConfigTemplate = await admin.remoteConfig().getTemplate();
const defaultVal = remoteConfigTemplate.parameters["video_max_duration"].defaultValue
const actualValue = defaultVal.value;
const finalValue: number = Number(actualValue);
In the code above, I see that defaultVal
is of type RemoteConfigParameterValue?
. But how do I convert it to a number in typescript ??
I tried to cast the defaultValue but this does not work...
const defaultVal = remoteConfigTemplate.parameters["video_max_duration"].defaultValue as ExplicitParameterValue
The error is Cannot find name 'ExplicitParameterValue'.ts(2304)
What is still wrong ?
Is there another way of getting a Firebase Remote Config defaultValue into a firebase function ?
来源:https://stackoverflow.com/questions/63307572/how-to-get-remoteconfig-defaultvalue-inside-firebase-function