Result of API Request to global variable?

I have an API Request for weather and the account of this weather stuff has a limitation of requests per minute. In my theme I have the weather information twice on the same page. So if I would make a function of the request it would fire twice. I thought about a global variable, where I could save the request once and grap this variable where ever I want.

Is this a good idea? I read something about, that global variables aren't a good choice!? Is there an other solution?

Topic globals variables Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.