fix: 商品生图助手容错 — API 返回非数组时设空数组避免崩溃
This commit is contained in:
parent
d8d49f7e88
commit
785db9277d
@ -67,7 +67,10 @@ export default function ImagePage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(API)
|
fetch(API)
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(setImages)
|
.then(data => {
|
||||||
|
setImages(Array.isArray(data) ? data : [])
|
||||||
|
})
|
||||||
|
.catch(() => setImages([]))
|
||||||
.finally(() => setLoading(false))
|
.finally(() => setLoading(false))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user