I know this is very basic thing but i need to know that how can i declare / assign value / use global variables.
because i have already declared variable global here it is :
now i am adding value which is geeting from server response like
now in console i am getting output in that global variable.
now, my problem is when i use that global variables values as param value to call API it will take ZERO. not getting correct value
Thanks for guide
Just remove var keyword from the local variable where you assign values and add below code instead.
global_userid = ["\(oDict["userResult"][0]["user_id"])"]
global_reqid = ["\(oDict["userResult"][0]["request_id"])"]
Related
I would like to use an api key stored in an environment variable. I know I can just put it directly in the html (I don't think it is bad security wise since it is a public key). But I can't get access it an my react component.
useEffect(()=>{
SetRecaptchaKey(import.meta.env.VITE_SITE_RECAPTCHA_KEY);
console.log(recaptchaKey)
});
outside my component function (above) I have this:
const key = import.meta.env;
console.log(key)
it logs the object in the console, and it has the variable i'm looking for.
Another thing, is that I have two VITE_... variables and another variable. Only one of VITE_.. is loaded (which is what I want) but I don't understand why.
Thanks in advance
In order to use an environment variable in client side Astro, you need to prefix the variable with "ASTRO_". For example, if you have an environment variable named "TEST_VAR", you would access it in client side Astro as "ASTRO_TEST_VAR".
I am learning dart and this behavior of dart is annoying me
var a=10;
a="John"; //it generates an error, because a has integer data-type and we can't assign
//string or the value of any other data type because we have assigned an
//integer value
but at the same time, dart allows us to write
var a;
a=10;
a="John";
print (a) //it displays John
it means that we can't assign the value of any other data type when a variable initializes at the time of declaration but we can assign the value of any other data type if the variable declares in one line and initializes at the second line. Why does dart work in this way?
The var keyword is used to let Dart automatically assign a type for the variable based on the value you are using to initialize the variable.
If you use var without providing any initial value, the type of your variable are automatically being assign to dynamic which allows any type of object to be assigned to the variable. But it also means your program are much less type safe since the analyzer can no longer help you with what type the variable are going to return and what types are allowed when setting the variable.
So in your first example, a is being assigned the type int since you provide 10 as the initial value. It is therefore a compile error when you are trying to set a String as the new value of your int variable.
In your second example, a is going to be dynamic since you are not providing any initial value. So it is not a problem to first give it 10 and later 'John' since dynamic allow us to use any type. But that also means that when we try to use a in our program, Dart cannot make any guarantees about what type of object you are going to get so errors will first be identified at runtime.
That's because var means dart will assign the type of variable itself.
In first case, the dart assigned variable a as int type because it was given a value during initialisation.
But in second case, the dart assigned variable a as dynamic and that's why you can assign it either a string or int later on.
https://www.twilio.com/docs/studio/widget-library#run-function
When you invoke a Function, you have two possible options for using variables: (1) you can pass Flow variables as parameters into a Function (e.g. flow.data.foo), and (2) you may set Flow variables with data returned from the Function (TwiML or JSON can be returned).
Does anyone know how to set Flow variables with data returned from a Function?
You should be able to follow the Liquid Syntax documented here, to do so.
Liquid Template Language - Assigning Variables
https://www.twilio.com/docs/studio/user-guide/liquid-template-language#variable-assignment
Or just call the returned variable by addressing the Function widget as shown at the link below:
https://www.twilio.com/docs/studio/widget-library#run-function
widgets.MY_FUCTION_WIDGET_NAME.parsed.xxxxx (where xxxxx is the JSON path).
Alan
I know how we can declare global variable in config file and then access through
Service Locator
Currently I am getting this Global variable in controller with the help of service locator and then pass it to models while creating object.
Question: Is it possible that I can get the Global variable in model directly rather than passing in all the models through controller?
Yes it is possible to get the variable declared in global file into model directly. Instead of declaring it as variable, just define it as constant in the global file so that you can access that variable easily in any models.
define('VAR_NAME',Value);
and access the variable using.
constant('VAR_NAME');
Hope it helps
Thanks
Is there a way to either create a new Environment Variable from within a WF 4.0 workflow or update an existing one if it already exists?
You can set a enviroment variable inside an code activity.
You can use the System.Activities.Statements.InvokeMethod activity to call the System.Environment.SetEnvironmentVariable static method.
In the Parameters setting, you'll need to pass 2 'In' parameters. The first will be the name of your environment variable, the 2nd will be the value.