heres my script:
local HttpService = game:GetService("HttpService")
local apiKey = "5bcec9b848mshb94162050789960p1c6280jsn3ca0120e8036"
local function formatDate(year, month, day)
return string.format("%04d-%02d-%02d", year, month, day)
end
local startYear = 2017
local startMonth = 2
local startDay = 20
local today = os.date("*t")
local yesterday = os.time({
year = today.year,
month = today.month,
day = today.day - 1,
hour = 0,
min = 0,
sec = 0
})
local yesterdayTable = os.date("*t", yesterday)
if yesterdayTable.day == 0 then
yesterdayTable.month = yesterdayTable.month - 1
if yesterdayTable.month == 0 then
yesterdayTable.year = yesterdayTable.year - 1
yesterdayTable.month = 12
end
yesterdayTable.day = os.date("*t", os.time({year = yesterdayTable.year, month = yesterdayTable.month + 1, day = 0})).day
end
local startDate = formatDate(startYear, startMonth, startDay)
local endDate = formatDate(yesterdayTable.year, yesterdayTable.month, yesterdayTable.day)
local apiUrl = "https://cash4life.p.rapidapi.com/History?startDate=" .. startDate .. "&endDate=" .. endDate
local function fetchData()
local headers = {
["X-RapidAPI-Key"] = apiKey,
["X-RapidAPI-Host"] = "cash4life.p.rapidapi.com"
}
local success, result = pcall(function()
return HttpService:RequestAsync({
Url = apiUrl,
Method = "GET",
Headers = headers
})
end)
if success then
local data = HttpService:JSONDecode(result.Body)
print(data
heres my output im having trouble with:
20:06:27.895 ▼ {
["message"] = "Invalid date! Please enter a date in the format of yyyy-MM-dd",
["status"] = "error"
} - Server - Script:52
20:06:27.895 Total Draws: 0 - Server - Script:61
** You are now Level 1! **