chore: cleanup functions
This commit is contained in:
parent
bf194a8545
commit
f5e6ef679b
@ -5,21 +5,26 @@ export const onRequest: PagesFunction<Env> = async (context) => {
|
|||||||
const id = context.params.id as string;
|
const id = context.params.id as string;
|
||||||
|
|
||||||
const next = await context.next();
|
const next = await context.next();
|
||||||
console.debug(next.status);
|
try {
|
||||||
console.debug("Fetching data for: ", id);
|
const rsp = await fetch(`https://api.snort.social/api/v1/og/tag/e/${id}`, {
|
||||||
|
method: "POST",
|
||||||
const rsp = await fetch(`https://api.snort.social/api/v1/og/tag/e/${id}`, {
|
body: await next.arrayBuffer(),
|
||||||
method: "POST",
|
headers: {
|
||||||
body: await next.arrayBuffer(),
|
"content-type": "text/plain"
|
||||||
headers: {
|
}
|
||||||
"content-type": "text/plain"
|
});
|
||||||
|
if (rsp.ok) {
|
||||||
|
const body = await rsp.text();
|
||||||
|
if (body.length > 0) {
|
||||||
|
return new Response(body, {
|
||||||
|
headers: {
|
||||||
|
"content-type": "text/html"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
} catch {
|
||||||
console.debug(rsp.status, rsp.statusText);
|
// ignore
|
||||||
const body = await rsp.text();
|
}
|
||||||
return new Response(body, {
|
return next;
|
||||||
headers: {
|
|
||||||
"content-type": "text/html"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
@ -5,21 +5,26 @@ export const onRequest: PagesFunction<Env> = async (context) => {
|
|||||||
const id = context.params.id as string;
|
const id = context.params.id as string;
|
||||||
|
|
||||||
const next = await context.next();
|
const next = await context.next();
|
||||||
console.debug(next.status);
|
try {
|
||||||
console.debug("Fetching data for: ", id);
|
const rsp = await fetch(`https://api.snort.social/api/v1/og/tag/p/${id}`, {
|
||||||
|
method: "POST",
|
||||||
const rsp = await fetch(`https://api.snort.social/api/v1/og/tag/p/${id}`, {
|
body: await next.arrayBuffer(),
|
||||||
method: "POST",
|
headers: {
|
||||||
body: await next.arrayBuffer(),
|
"content-type": "text/plain"
|
||||||
headers: {
|
}
|
||||||
"content-type": "text/plain"
|
});
|
||||||
|
if (rsp.ok) {
|
||||||
|
const body = await rsp.text();
|
||||||
|
if (body.length > 0) {
|
||||||
|
return new Response(body, {
|
||||||
|
headers: {
|
||||||
|
"content-type": "text/html"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
} catch {
|
||||||
console.debug(rsp.status, rsp.statusText);
|
// ignore
|
||||||
const body = await rsp.text();
|
}
|
||||||
return new Response(body, {
|
return next;
|
||||||
headers: {
|
|
||||||
"content-type": "text/html"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user