upd: status respon
Deskripsi: - update status respon pada jabatan No Issues
This commit is contained in:
@@ -4,12 +4,12 @@ import { API_INDEX_POSITION } from "./api_index";
|
||||
|
||||
type Method = "GET" | "POST";
|
||||
export async function apiPosition(req: NextRequest, method: Method) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const path = searchParams.get("path");
|
||||
const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method);
|
||||
if (!path)
|
||||
return Response.json({ message: "page not found" }, { status: 404 });
|
||||
const { searchParams } = new URL(req.url);
|
||||
const path = searchParams.get("path");
|
||||
const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method);
|
||||
if (!path)
|
||||
return Response.json({ success: false, message: "page not found" }, { status: 404 });
|
||||
if (act) return act.bin(req);
|
||||
|
||||
return Response.json({ message: "404" });
|
||||
}
|
||||
|
||||
return Response.json({ success: false, message: "404" });
|
||||
}
|
||||
@@ -19,6 +19,6 @@ export async function getAllPosition(req: NextRequest) {
|
||||
return Response.json(positions);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ export async function createlPosition(req: Request) {
|
||||
return Response.json(positions, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user