I have a script that uses Openweathermap API for weather data, the problem is for some reason that data is not being received, and there are no errors in Output.
Script:
--API Data-
local Api_Key = "API key here"
local Api_City_Name = "New York"
local Api_Url = "https://api.openweathermap.org/data/2.5/weather?q="..Api_City_Name.."&appid="..Api_Key
--Get HttpService--
local HS = game:GetService("HttpService")
--Get Weather Data--
local Data = nil
local s, e = pcall(function()
Data = HS:GetAsync(Api_Url)
end)
if Data ~= nil then
Data = HS:JSONDecode(Data)
print(Data)
end
Json Output will look like raw data in browser. I’d recommend trying it in a browser before testing it with get requests. Also an API Key is not something you should share!
First of all, never leak API keys in the forum(I highly suggest you edit the post to set it to "") people can use them to make requests as you. Secondly the error may happen because you didn’t url encode the city name(urls don’t allow spaces):
local Api_City_Name = HS:UrlEncode("New York") --New%20York
This didn’t work for me either, what’s odd is there are as I mentioned no errors in output but there’s also no sign that the script is even running, I’m not sure if my output settings are messed up or what.