mirror of
https://github.com/sern-handler/frontpage-bot
synced 2026-06-06 01:16:54 +00:00
fix: convert empty string to null
This commit is contained in:
@@ -46,5 +46,6 @@
|
||||
"prisma": "^5.12.1",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5"
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
|
||||
@@ -24,9 +24,22 @@ export async function GET(req: Request) {
|
||||
verified: true
|
||||
}
|
||||
})
|
||||
return new Response(JSON.stringify(dbFetch), {
|
||||
return new Response(JSON.stringify(emptyValToNull(dbFetch)), {
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function emptyValToNull(obj: any) {
|
||||
for (const key in obj) {
|
||||
if (typeof obj[key] === 'object') {
|
||||
emptyValToNull(obj[key]);
|
||||
} else {
|
||||
if (obj[key] === '') {
|
||||
obj[key] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
Reference in New Issue
Block a user