19 : Math.floor((Date.now() - 2 * 24 * 60 * 60 * 1000) / 1000);
20
21 // Fetch and log tweets
22 const response = await socialDataSearch(`${query} since_time:${timeFrame}`);
23 console.log("Response from socialDataSearch:", response);
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
36// Zulip API helpers
37async function getStreamId(streamName) {
38 const response = await fetch(`${ZULIP_URL}/api/v1/get_stream_id?stream=${encodeURIComponent(streamName)}`, {
39 headers: {
40 "Authorization": `Basic ${btoa(`${ZULIP_BOT_EMAIL}:${ZULIP_BOT_KEY}`)}`,
46
47async function getStreamTopics(streamId) {
48 const response = await fetch(`${ZULIP_URL}/api/v1/users/me/${streamId}/topics`, {
49 headers: {
50 "Authorization": `Basic ${btoa(`${ZULIP_BOT_EMAIL}:${ZULIP_BOT_KEY}`)}`,
56
57async function sendMessage(stream, topic, content) {
58 const response = await fetch(`${ZULIP_URL}/api/v1/messages`, {
59 method: "POST",
60 headers: {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let spotifyAPI = ({ token, endpoint, ...params }) =>
4 fetchJSON(
5 `https://api.spotify.com/v1/${endpoint}${
6 "method" in params && ["POST", "PUT", "DELETE"].includes(params["method"])
172});
173
174export default app.fetch.bind(app);
175
176const css = `
52 try {
53 // Get access token
54 const response = await fetch("https://accounts.spotify.com/api/token", {
55 method: "POST",
56 headers: {
26
27 try {
28 const response = await fetch("/", {
29 method: "POST",
30 headers: { "authorization": "Bearer " + bearerToken },
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({