cerebras_coderindex1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
cerebras_coderindex1 match
5async function servePublicFile(path: string): Promise<Response> {
6const url = new URL("./public/" + path, import.meta.url);
7const text = await (await fetch(url, {
8headers: {
9"User-Agent": "", // to transpile TS to JS
cerebras_coderindex1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
12* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
test_projectscript.ts7 matches
3233useEffect(() => {
34fetchProblem();
35}, []);
3637const fetchProblem = async () => {
38setLoading(true);
39try {
40const response = await fetch("/problem");
41if (!response.ok) throw new Error("Failed to fetch problem");
42const data = await response.json();
43setProblem(data);
49setFeedbackRenderKey(0);
50} catch (error) {
51console.error("Error fetching problem:", error);
52setFeedback("Failed to load problem. Please try again.");
53} finally {
60setLoading(true);
61try {
62const response = await fetch("/check", {
63method: "POST",
64headers: { "Content-Type": "application/json" },
151)}
152{showCorrectAnswer && (
153<button onClick={fetchProblem} className="next-button">
154Try a new problem
155</button>
cerebras_coderindex1 match
5async function servePublicFile(path: string): Promise<Response> {
6const url = new URL("./public/" + path, import.meta.url);
7const text = await (await fetch(url, {
8headers: {
9"User-Agent": "", // to transpile TS to JS
cerebras_coderindex1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
twitterAlertmain.tsx1 match
19: Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
2021// Fetch and log tweets
22const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23console.log("Response from socialDataSearch:", response);
jobBoardChatAppmain.tsx13 matches
27useEffect(() => {
28if (username && valUrl) {
29fetchJobs();
30fetchMessages();
31const interval = setInterval(() => {
32fetchMessages();
33}, 5000);
34return () => clearInterval(interval);
36}, [username, valUrl]);
3738const fetchJobs = async () => {
39try {
40const response = await fetch(`${valUrl}?type=jobs`);
41const data = await response.json();
42console.log("Jobs data:", data); // Debug log
44setJobs(Array.isArray(data) ? data : (data.rows || []));
45} catch (error) {
46console.error("Failed to fetch jobs:", error);
47setJobs([]); // Fallback to empty array
48}
49};
5051const fetchMessages = async () => {
52try {
53const response = await fetch(`${valUrl}?type=messages`);
54const data = await response.json();
55console.log("Messages data:", data); // Debug log
57setMessages(Array.isArray(data) ? data : (data.rows || []));
58} catch (error) {
59console.error("Failed to fetch messages:", error);
60setMessages([]); // Fallback to empty array
61}
65e.preventDefault();
66try {
67await fetch(valUrl, {
68method: "POST",
69headers: { "Content-Type": "application/json" },
71});
72setNewJob({ title: "", company: "", description: "" });
73fetchJobs();
74} catch (error) {
75console.error("Failed to post job:", error);
84}
85try {
86await fetch(valUrl, {
87method: "POST",
88headers: { "Content-Type": "application/json" },
90});
91setNewMessage("");
92fetchMessages();
93} catch (error) {
94console.error("Failed to send message:", error);
blob_adminapp.tsx22 matches
231const [isDragging, setIsDragging] = useState(false);
232233const fetchBlobs = useCallback(async () => {
234setLoading(true);
235try {
236const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237const data = await response.json();
238setBlobs(data);
239} catch (error) {
240console.error("Error fetching blobs:", error);
241} finally {
242setLoading(false);
245246useEffect(() => {
247fetchBlobs();
248}, [fetchBlobs]);
249250const handleSearch = (e) => {
261setBlobContentLoading(true);
262try {
263const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264const content = await response.text();
265setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
266setEditContent(content);
267} catch (error) {
268console.error("Error fetching blob content:", error);
269} finally {
270setBlobContentLoading(false);
275const handleSave = async () => {
276try {
277await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278method: "PUT",
279body: editContent,
287const handleDelete = async (key) => {
288try {
289await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290setBlobs(blobs.filter(b => b.key !== key));
291if (selectedBlob && selectedBlob.key === key) {
304const key = `${searchPrefix}${file.name}`;
305formData.append("key", encodeKey(key));
306await fetch("/api/blob", { method: "POST", body: formData });
307const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308setBlobs([newBlob, ...blobs]);
312}
313}
314fetchBlobs();
315};
316326try {
327const fullKey = `${searchPrefix}${key}`;
328await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329method: "PUT",
330body: "",
341const handleDownload = async (key) => {
342try {
343const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344const blob = await response.blob();
345const url = window.URL.createObjectURL(blob);
360if (newKey && newKey !== oldKey) {
361try {
362const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363const content = await response.blob();
364await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365method: "PUT",
366body: content,
367});
368await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370if (selectedBlob && selectedBlob.key === oldKey) {
380const newKey = `__public/${key}`;
381try {
382const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383const content = await response.blob();
384await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385method: "PUT",
386body: content,
387});
388await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390if (selectedBlob && selectedBlob.key === key) {
399const newKey = key.slice(9); // Remove "__public/" prefix
400try {
401const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402const content = await response.blob();
403await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404method: "PUT",
405body: content,
406});
407await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409if (selectedBlob && selectedBlob.key === key) {