Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function searchTweets({ accessToken, query, params }: {
accessToken: string;
query: string;
params?: Record<string, string>;
}) {
const q = new URLSearchParams({ query, ...params }).toString();
const results = await fetchJSON(
`https://api.twitter.com/2/tweets/search/recent?${q}`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
);
return results.data;
}
October 23, 2023