You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/?q=api&page=5&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=api
Returns an array of strings in format "username" or "username/projectName"
Found 18780 results for "api"(1887ms)
1617const load = async () => {
18const res = await fetch("/api/todos");
19const data: Todo[] = await res.json();
20setTodos(data);
27const add = async (e: React.FormEvent) => {
28e.preventDefault();
29await fetch("/api/todos", {
30method: "POST",
31headers: { "Content-Type": "application/json" },
3738const complete = async (id: number) => {
39await fetch("/api/complete", {
40method: "POST",
41headers: { "Content-Type": "application/json" },
44const url = new URL(req.url);
45const data = await req.json();
46if (url.pathname.endsWith("/api/todos")) {
47db.prepare("INSERT INTO todos (text) VALUES (?)").run(data.text);
48return new Response("ok");
49}
50if (url.pathname.endsWith("/api/complete")) {
51const id = data.id;
52const today = getToday();