Update +page.server.js

This commit is contained in:
freearhey 2023-10-10 05:41:22 +03:00
parent 46c3780592
commit 768357b9ef

View file

@ -1,3 +1,4 @@
import { error } from '@sveltejs/kit'
import { transformChannel } from '~/store' import { transformChannel } from '~/store'
import _ from 'lodash' import _ from 'lodash'
import channels from '~/data/channels.json' import channels from '~/data/channels.json'
@ -35,12 +36,12 @@ export function load({ params }) {
const name = params.name const name = params.name
const id = `${name}.${country}`.toLowerCase() const id = `${name}.${country}`.toLowerCase()
let channel = data.channels[id] || {} let channel = data.channels[id]
if (channel) { if (!channel) {
channel = transformChannel(channel, data) throw error(404, 'Not Found')
} }
return { return {
channel channel: transformChannel(channel, data)
} }
} }