1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { fetch } from "https://esm.town/v/std/fetch";
export const searchArXiV = async ({ query = "", start = 0, max_results = 10 }) => {
const { parseStringPromise } = await import("npm:xml2js");
const url = new URL("https://export.arxiv.org/api/query");
url.searchParams.set("search_query", query);
url.searchParams.set("start", start);
url.searchParams.set("max_results", max_results);
const response = await fetch(url.toString());
const text = await response.text();
if (!response.ok) {
throw new Error(text);
}
const feed = await parseStringPromise(text);
return feed;
};
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!
v3
October 23, 2023