forked from ttc/micro-service-api
-first commit
This commit is contained in:
24
exthernal-login-api/src/utils/response.js
Normal file
24
exthernal-login-api/src/utils/response.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// ===================================================
|
||||
// ⚙️ Nuttakit Response Layer vFinal++++++
|
||||
// ===================================================
|
||||
|
||||
export function sendError(thMsg = 'เกิดข้อผิดพลาดไม่คาดคิดเกิดขึ้น', enMsg = 'Unexpected error', code = 400) {
|
||||
return {
|
||||
code: String(code),
|
||||
message: enMsg,
|
||||
message_th: thMsg,
|
||||
data: []
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
// 🔹 Auto Success Response (ใช้โดย Global Handler เท่านั้น)
|
||||
// ===================================================
|
||||
export function formatSuccessResponse(data) {
|
||||
return {
|
||||
code: "200",
|
||||
message: "successful",
|
||||
message_th: "ดำเนินการสำเร็จ",
|
||||
data: data || null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user