bridge_ui: support more nft metadata formats

Change-Id: I61d27190473b24aad56237b76665d57c466c9833
This commit is contained in:
Evan Gray 2021-10-26 13:51:12 -04:00
parent a1fc5acaba
commit bddfa07bc2
1 changed files with 13 additions and 5 deletions

View File

@ -249,19 +249,27 @@ export default function NFTViewer({
try { try {
const result = await axios.get(uri); const result = await axios.get(uri);
if (!cancelled && result && result.data) { if (!cancelled && result && result.data) {
// support returns with nested data (e.g. {status: 10000, result: {data: {...}}})
const data = result.data.result?.data || result.data;
setMetadata({ setMetadata({
uri, uri,
image: result.data.image, image:
animation_url: result.data.animation_url, data.image ||
nftName: result.data.name, data.image_url ||
description: result.data.description, data.big_image ||
data.small_image,
animation_url: data.animation_url,
nftName: data.name,
description: data.description,
isLoading: false, isLoading: false,
}); });
} else if (!cancelled) { } else if (!cancelled) {
setMetadata((m) => ({ ...m, isLoading: false })); setMetadata((m) => ({ ...m, isLoading: false }));
} }
} catch (e) { } catch (e) {
setMetadata((m) => ({ ...m, isLoading: false })); if (!cancelled) {
setMetadata((m) => ({ ...m, isLoading: false }));
}
} }
})(); })();
return () => { return () => {