mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
Safe json parsing for video/image links
This commit is contained in:
parent
52f57d32bc
commit
d5f3808eca
1 changed files with 8 additions and 2 deletions
|
|
@ -20,6 +20,12 @@ export default async function handler(req, res) {
|
|||
maxRecords: 1
|
||||
})
|
||||
|
||||
let screenshot
|
||||
try { screenshot = JSON.parse(project.fields['ScreenshotLinks']) } catch { screenshot = [] }
|
||||
|
||||
let video
|
||||
try { video = JSON.parse(project.fields['VideoLinks']) } catch { video = [] }
|
||||
|
||||
const results = project.map(p => ({
|
||||
id: p.id,
|
||||
title: p.fields['Name'] || '',
|
||||
|
|
@ -33,8 +39,8 @@ export default async function handler(req, res) {
|
|||
user: user.fields['Name'],
|
||||
color: p.fields['color'] || '',
|
||||
textColor: p.fields['textColor'] || '',
|
||||
screenshot: JSON.parse(p.fields['ScreenshotLinks']) || [],
|
||||
video: JSON.parse(p.fields['VideoLinks']) || []
|
||||
screenshot,
|
||||
video,
|
||||
}))
|
||||
return res.status(200).json({ project: results[0] })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue