You can, it'd be the same result just wouldn't be considered a nice style. It's a common practice to declare your variables together at the begging of the code e.g. if the api url changes you only have to change it in one place and don't have to hunt the code looking for every occurrence.