makeWebRequest error 400 for position data on VA3M

I just troubleshooted this issue and thought it might be helpful for anyone else who encounters something similar...

I set up a makeWebRequest process to get temperature from OpenWeatherMap to output on a watch face. One of the input parameters is position coordinates from the device. I found that the simulator defaults to [lat, lon] = [0, 0], but an actual device might default to something else if there is no other position data available.

With my vivoactive 3 Music, I noticed it behaved differently from the simulator, so I assumed the default position was "null" if I turned off the watch and back on again without getting a GPS reading. However, the position data sneaked past my null checks and I got a response code of 400 from the API call (that's 400 and not -400). In case you don't know, the 400 code means the server has an issue with something in the API call coming from the client, so it rejects it. I finally outputted the position data to the watch screen itself so I could see it, and it was defaulting to [180, 180], which are invalid coordinates. Latitude ranges between -90 and 90, and longitude ranges between -180 and 180. So the value actually wasn't null, but OpenWeatherMap rejected my API call because the coordinates were not valid.

In my code, I added an if statement to make sure [lat, lon] was within bounds, and now it works.

Something else with the VA3M (and probably other devices) is that when the screen is unlocked or the settings changed, it reset a global variable for the temperature reading that I had declared at the top of the App file. To avoid having the value change every time on the watch face, I needed to put it into storage when appropriate.