Help with APIs and GitHub

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.

try printing data. What does that return? print(data)

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

It gets the data raw, byut how can I get the name property.

1 Like

The data returned is an array.

Try data[1].name instead.

1 Like

I understand now, thanks for the help.

2 Likes