playgroundwordpress.ts20 matches
81}
8283// Fetch posts with optional parameters
84export async function getPosts(params: {
85page?: number;
102103const url = `${API_URL}/posts?${queryParams.toString()}`;
104const response = await fetch(url);
105
106if (!response.ok) {
107throw new Error(`Failed to fetch posts: ${response.status} ${response.statusText}`);
108}
109
111}
112113// Fetch a single post by slug
114export async function getPostBySlug(slug: string): Promise<Post> {
115const posts = await getPosts({ slug, embed: true });
122}
123124// Fetch pages with optional parameters
125export async function getPages(params: {
126page?: number;
139140const url = `${API_URL}/pages?${queryParams.toString()}`;
141const response = await fetch(url);
142
143if (!response.ok) {
144throw new Error(`Failed to fetch pages: ${response.status} ${response.statusText}`);
145}
146
148}
149150// Fetch a single page by slug
151export async function getPageBySlug(slug: string): Promise<Page> {
152const pages = await getPages({ slug, embed: true });
159}
160161// Fetch categories
162export async function getCategories(): Promise<Category[]> {
163const url = `${API_URL}/categories?per_page=100`;
164const response = await fetch(url);
165
166if (!response.ok) {
167throw new Error(`Failed to fetch categories: ${response.status} ${response.statusText}`);
168}
169
171}
172173// Fetch tags
174export async function getTags(): Promise<Tag[]> {
175const url = `${API_URL}/tags?per_page=100`;
176const response = await fetch(url);
177
178if (!response.ok) {
179throw new Error(`Failed to fetch tags: ${response.status} ${response.statusText}`);
180}
181
183}
184185// Fetch media
186export async function getMedia(id: number): Promise<Media> {
187const url = `${API_URL}/media/${id}`;
188const response = await fetch(url);
189
190if (!response.ok) {
191throw new Error(`Failed to fetch media: ${response.status} ${response.statusText}`);
192}
193
195}
196197// Fetch site info
198export async function getSiteInfo() {
199const url = 'https://mehr-research.science/wp-json';
200const response = await fetch(url);
201
202if (!response.ok) {
203throw new Error(`Failed to fetch site info: ${response.status} ${response.statusText}`);
204}
205
playgroundindex.ts1 match
48});
4950export default app.fetch;
playgroundREADME.md2 matches
1# Astro Frontend for mehr-research.science
23This project is an Astro-based frontend for the WordPress website mehr-research.science. It uses the WordPress REST API to fetch content and display it in a modern, fast interface.
45## Project Structure
13## Features
1415- Fetches posts, pages, and other content from WordPress REST API
16- Fast, static-first rendering with Astro
17- Responsive design
demo-ai-mamain.js1 match
94content.push({ type: 'text', text: prompt });
95
96const response = await fetch('https://api.anthropic.com/v1/messages', {
97method: 'POST',
98headers: {
umbrellaRemindermain.tsx1 match
1export async function testReminder() {
2fetch('https://jsonplaceholder.typicode.com/todos/1')
3.then(response => response.json())
4.then(json => console.log(json)
umbrellaRemindermain.tsx2 matches
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14lon,
15});
16let { properties: { periods } } = await fetchJSON(
17grid.forecastHourly,
18);
TownieuseUser.tsx4 matches
8const [error, setError] = useState(null);
910const fetchData = async () => {
11try {
12const userEndpoint = new URL(USER_ENDPOINT, window.location.origin);
1314const res = await fetch(userEndpoint);
15const data = await res.json();
16if (!res.ok) {
3334useEffect(() => {
35fetchData();
36}, []);
3738return { data, loading, error, refetch: fetchData };
39}
40
TownieuseProject.tsx5 matches
9const [error, setError] = useState(null);
1011const fetchData = async () => {
12try {
13const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
17if (branchId) filesEndpoint.searchParams.append("branchId", branchId);
1819const { project } = await fetch(projectEndpoint).then((res) =>
20res.json()
21);
22const { files } = await fetch(filesEndpoint).then((res) => res.json());
2324setData({ project, files });
34useEffect(() => {
35if (!projectId) return;
36fetchData();
37}, [projectId, branchId]);
3839return { data, loading, error, refetch: fetchData };
40}
41
TownieuseProjects.tsx4 matches
8const [error, setError] = useState(null);
910const fetchData = async () => {
11try {
12const res = await fetch(ENDPOINT);
13const data = await res.json();
14if (!res.ok) {
3233useEffect(() => {
34fetchData();
35}, []);
3637return { data, loading, error, refetch: fetchData };
38}
39
TownieuseCreateProject.tsx1 match
19setError(null);
20try {
21const res = await fetch(ENDPOINT, {
22method: "POST",
23headers: {