jjjbad
(jjjbad)
December 19, 2021, 12:34pm
1
In a normal script I have this code:
function getStatus()
print("Fetching status...")
local httpService = game:GetService("HttpService")
local url = "https://api.github.com"
local data = httpService:GetAsync(url .. "/repos/callmehSpear/Moonlight-Framework/releases")
data = httpService:JSONDecode(data)
print(data.name)
end
getStatus()
But it returns nil.Could someone help.
majdTRM
(majdTRM)
December 19, 2021, 1:00pm
3
try printing data. What does that return? print(data)
jjjbad
(jjjbad)
December 19, 2021, 1:05pm
4
Returns this
13:05:21.301 ▼ {
[1] = ▼ {
["assets"] = {},
["assets_url"] = "https://api.github.com/repos/callmehSpear/Moonlight-Framework/releases/55618239/assets",
["author"] = ▶ {...},
["body"] = "This is the initial release of the Moonlight Framework for Roblox.
# What's new?
- Added initial README.md, LICENSE and MainModule.lua scripts to repo.
- Added install steps.
# Install
local moon = require(8288681721)
# Documentation
Documentation can be found<a href="https://github.com/callmehSpear/Moonlight-Framework/wiki"> here</a>.",
["created_at"] = "2021-12-19T10:58:23Z",
["draft"] = false,
["html_url"] = "https://github.com/callmehSpear/Moonlight-Framework/releases/tag/0.0.1",
["id"] = 55618239,
["name"] = "v0.0.1 Initial Release",
["node_id"] = "RE_kwDOGjc2OM4DUKq_",
["prerelease"] = false,
["published_at"] = "2021-12-19T11:01:56Z",
["tag_name"] = "0.0.1",
["tarball_url"] = "https://api.github.com/repos/callmehSpear/Moonlight-Framework/tarball/0.0.1",
["target_commitish"] = "main",
["upload_url"] = "https://uploads.github.com/repos/callmehSpear/Moonlight-Framework/releases/55618239/assets{?name,label}",
["url"] = "https://api.github.com/repos/callmehSpear/Moonlight-Framework/releases/55618239",
["zipball_url"] = "https://api.github.com/repos/callmehSpear/Moonlight-Framework/zipball/0.0.1"
}
} - Server - Script:8
jjjbad
(jjjbad)
December 19, 2021, 1:06pm
5
It gets the data raw, byut how can I get the name property.
1 Like
majdTRM
(majdTRM)
December 19, 2021, 1:08pm
6
The data returned is an array.
Try data[1].name
instead.
1 Like
jjjbad
(jjjbad)
December 19, 2021, 1:09pm
7
majdTRM:
data[1].name
I understand now, thanks for the help.
2 Likes