Public
Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export default async function fetchNewPublicGitHubRepos() {
// Generate today's date in YYYY-MM-DD format
const today = new Date().toISOString().split("T")[0];
const query = `created:>=${today}`;
const sort = "created";
const order = "desc";
const url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&order=${order}`;
const response = await fetch(url, {
headers: {
"Accept": "application/vnd.github.v3+json",
"User-Agent": "Deno-GitHub-Repo-Fetcher", // GitHub API requires a user-agent header
},
});
if (!response.ok) {
throw new Error(`GitHub API responded with status: ${response.status}`);
}
return response.json();
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
April 4, 2024