260806_01_ENH: 문자 템플릿 저장 json에서 form 방식으로 교체
This commit is contained in:
@@ -42,7 +42,11 @@ export const PATCH = async (
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const body = await req.json().catch(() => null) as SaveTemplateRequest | null;
|
||||
const formData = await req.formData();
|
||||
const templatePart = formData.get("template");
|
||||
const body = templatePart instanceof Blob
|
||||
? JSON.parse(await templatePart.text()) as SaveTemplateRequest
|
||||
: null;
|
||||
if (!body || !body.tmplatIdx) {
|
||||
return NextResponse.json({ message: "Template request body is invalid." }, { status: 400 });
|
||||
}
|
||||
@@ -57,7 +61,13 @@ export const PATCH = async (
|
||||
sendTel: body.sendTel,
|
||||
};
|
||||
|
||||
await notiHubApi.patch<void>("/template", next);
|
||||
const backendForm = new FormData();
|
||||
backendForm.append(
|
||||
"template",
|
||||
new Blob([JSON.stringify(next)], {type: "application/json"})
|
||||
);
|
||||
|
||||
await notiHubApi.patchForm<void>("/template", backendForm);
|
||||
|
||||
return NextResponse.json(next, { status: 200 });
|
||||
} catch (error: unknown) {
|
||||
|
||||
Reference in New Issue
Block a user