I’m attempting to use .js
, using glitch, to retrieve Roblox’s API endpoint - however, it tends to return an empty JSON table {}
, which potentially is a fault in the code. I don’t prior knowledge of .js as much with Lua, hence that’d be the case of misunderstanding operations:
const express = require("express")
const app = express()
var fetch = require("node-fetch")
app.get("/proxy", (req, res) => {
//https://glitchDomain.me/proxy?api=users.roblox.com/v1/users/121227196
var api = req.query["api"] //getting query
var url = "https://" + api //adding "https://" onto the api for "absolute URL"
var data = fetch(url, {method: "GET", headers: {}})
console.log(data) //outputs "Promise { <pending> }"
res.json(data) //send back the result with json encoding?
})
It still shows me Promise { <pending> }
in console.log(result)
. (replenished code. see edit for the old one.)
--[ Variables
local http = game:GetService("HttpService")
local url = "https://glitchDomain.me"
local api = "users.roblox.com"
local userId = 121227196
--[ Setup
url = url.."/proxy?api="..api.."/v1/users/"..userId
print(url)
--https://glitchDomain.me/proxy?api=users.roblox.com/v1/users/121227196
local data = http:GetAsync(url)
print(data)
--{}
data = http:JSONDecode(data)
print(data)
--{}