mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-30 02:12:38 +03:00
16 lines
364 B
JavaScript
16 lines
364 B
JavaScript
|
import * as Data from "~/node_common/data";
|
||
|
|
||
|
export const getRandomSlateElementURL = async ({ id, fallback }) => {
|
||
|
if (!{ id }) {
|
||
|
return { fallback };
|
||
|
}
|
||
|
|
||
|
const query = await Data.getSlateById({ id });
|
||
|
|
||
|
if (!query || query.error) {
|
||
|
return { fallback };
|
||
|
}
|
||
|
|
||
|
return query.data.objects[Math.floor(Math.random() * query.data.objects.length)].url;
|
||
|
};
|