Greatly reduce repeated code
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { jsonError } from "../../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { appeal } = context.data;
|
||||
const body = new FormData();
|
||||
@ -20,12 +22,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
|
||||
if (!emailReq.ok) {
|
||||
console.log(await emailReq.json());
|
||||
return new Response('{"error":"Failed to deny appeal"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 500,
|
||||
});
|
||||
return jsonError("Failed to deny appeal", 500);
|
||||
}
|
||||
|
||||
await context.env.D1.prepare("UPDATE appeals SET open = 0 WHERE id = ?;")
|
||||
|
Reference in New Issue
Block a user