-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_github.mjs
More file actions
29 lines (27 loc) · 1.01 KB
/
Copy pathtest_github.mjs
File metadata and controls
29 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Just check environment
console.log("Hello from .mjs");
console.log("GITHUB_TOKEN:", process.env.GITHUB_TOKEN ? "YES (" + process.env.GITHUB_TOKEN.substring(0,4) + "...)" : "NO");
console.log("All keys:", Object.keys(process.env).filter(k => k.includes("GITHUB") || k.includes("TOKEN") || k=== "NODE_ENV"));
// Try fetch via dynamic import
const mod = await import("https");
console.log("https module loaded");
// Make request
const req = mod.get("https://api.github.com/orgs/studio-immens", {
headers: {
"User-Agent": "OpenClaw/1.0",
...(process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {})
}
}, (res) => {
let body = "";
res.on("data", d => body += d);
res.on("end", () => {
try {
const j = JSON.parse(body);
console.log("Status:", res.statusCode);
console.log("Response:", JSON.stringify(j, null, 2).substring(0, 2000));
} catch {
console.log("Body:", body.substring(0, 500));
}
});
});
req.on("error", e => console.error("Error:", e));