28 const authHeader = req.headers.get("Proxy-Authorization") || req.headers.get("Authorization");
29 const token = authHeader ? parseBearerString(authHeader) : undefined;
30 const meRes = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${token}` } });
31 if (!meRes.ok) {
32 return new Response("Unauthorized", { status: 401 });
63 });
64
65 const openAIRes = await fetch(url, {
66 method: req.method,
67 headers,
210 }
211 }
212 const response = await fetch(createEndpointUrl("invoke"), {
213 method: "POST",
214 body: JSON.stringify(body),
220};
221
222const data = await (await fetch(createEndpointUrl("describe"), { method: "POST" }))
223 .json() as NodeDescriberResult;
224
115 const body = await req.json() as { $key: string };
116 body.$key = $key;
117 const response = await fetch(endpointURL, {
118 method: "POST",
119 headers: {
94 tokenUrl.searchParams.set("state", store.state);
95
96 const tokenResp = await fetch(tokenUrl.toString());
97 if (!tokenResp.ok) {
98 throw new Error(await tokenResp.text());
103 };
104
105 const resp = await fetch("https://lastlogin.io/userinfo", {
106 headers: {
107 Authorization: `Bearer ${access_token}`,
123 const body = await req.json() as { $key: string };
124 body.$key = $key;
125 const response = await fetch(endpointURL, {
126 method: "POST",
127 headers: {
62 // Load props data from API
63 async function loadProps() {
64 const statePropsData = await fetch("/api/state-props").then(res => res.json());
65 setStateProps(statePropsData);
66 }
72 // Load user choices from server
73 async function loadUserChoices() {
74 const choices = await fetch(`/api/user-choices?id=${userID}`).then(res => res.json());
75 setUserChoices(choices);
76 }
84 // Save user choices to server
85 if (userID) {
86 fetch(`/api/user-choices?id=${userID}`, {
87 method: "POST",
88 headers: {
20 try {
21 const url = constructSearchUrl(query);
22 const response = await fetch(url);
23 if (!response.ok) {
24 throw new Error(`HTTP error! status: ${response.status}`);
294 const email = document.getElementById('email').value;
295 try {
296 const response = await fetch('/api/subscribe', {
297 method: 'POST',
298 headers: { 'Content-Type': 'application/json' },
35 const puzzlePDFUrl = nytCrosswordURLPrefix + puzzleName + ".pdf";
36
37 console.log("Fetching " + puzzleName + " from " + puzzlePDFUrl + "...");
38
39 request({
139 const saveSequence = async () => {
140 try {
141 const response = await fetch("/api/save-sequence", {
142 method: "POST",
143 headers: {
159 const loadSequence = async () => {
160 try {
161 const response = await fetch("/api/load-sequence");
162 if (response.ok) {
163 const savedSequence = await response.json();