Spaces:
Runtime error
Runtime error
~handle missing cardData case
Browse files- pages/api/hf_space.js +4 -5
pages/api/hf_space.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
const get_space_info = async (space_id) => {
|
3 |
try {
|
4 |
const response = await fetch(`https://huggingface.co/api/spaces/${space_id}`)
|
@@ -14,10 +13,10 @@ const get_space_info = async (space_id) => {
|
|
14 |
const lastModified = dayjs(json.lastModified).fromNow()
|
15 |
|
16 |
const author = json.author
|
17 |
-
const title = json.cardData
|
18 |
-
const emoji = json.cardData
|
19 |
-
let colorFrom = json.cardData
|
20 |
-
let colorTo = json.cardData
|
21 |
const likes = json.likes
|
22 |
const sdk = json.sdk
|
23 |
const runtime_stage = json.runtime.stage
|
|
|
|
|
1 |
const get_space_info = async (space_id) => {
|
2 |
try {
|
3 |
const response = await fetch(`https://huggingface.co/api/spaces/${space_id}`)
|
|
|
13 |
const lastModified = dayjs(json.lastModified).fromNow()
|
14 |
|
15 |
const author = json.author
|
16 |
+
const title = json.cardData?.title || json.id.split('/')[1].replace(/-/g, ' ') || 'Untitled'
|
17 |
+
const emoji = json.cardData?.emoji || 'π€'
|
18 |
+
let colorFrom = json.cardData?.colorFrom || 'pink'
|
19 |
+
let colorTo = json.cardData?.colorTo || 'purple'
|
20 |
const likes = json.likes
|
21 |
const sdk = json.sdk
|
22 |
const runtime_stage = json.runtime.stage
|