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 {
const result = await axios.get(uri);
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({
uri,
image: result.data.image,
animation_url: result.data.animation_url,
nftName: result.data.name,
description: result.data.description,
image:
data.image ||
data.image_url ||
data.big_image ||
data.small_image,
animation_url: data.animation_url,
nftName: data.name,
description: data.description,
isLoading: false,
});
} else if (!cancelled) {
setMetadata((m) => ({ ...m, isLoading: false }));
}
} catch (e) {
setMetadata((m) => ({ ...m, isLoading: false }));
if (!cancelled) {
setMetadata((m) => ({ ...m, isLoading: false }));
}
}
})();
return () => {