diff --git a/packages/builder/src/components/common/LinkedRecordSelector.svelte b/packages/builder/src/components/common/LinkedRecordSelector.svelte index 8b20a8e3ac..e7cf245eb8 100644 --- a/packages/builder/src/components/common/LinkedRecordSelector.svelte +++ b/packages/builder/src/components/common/LinkedRecordSelector.svelte @@ -8,17 +8,24 @@ export let schema export let linkedRecords = [] + let records = [] + $: label = capitalise(schema.name) $: linkedModelId = schema.modelId $: linkedModel = $backendUiStore.models.find( model => model._id === linkedModelId ) - $: promise = fetchRecords(linkedModelId) + $: fetchRecords(linkedModelId) async function fetchRecords(linkedModelId) { const FETCH_RECORDS_URL = `/api/${linkedModelId}/records` - const response = await api.get(FETCH_RECORDS_URL) - return await response.json() + try { + const response = await api.get(FETCH_RECORDS_URL) + records = await response.json() + } catch (error) { + console.log(error) + records = [] + } } function getPrettyName(record) { @@ -34,15 +41,13 @@ table. {:else} - {#await promise then records} - - {#each records as record} - - {/each} - - {/await} + + {#each records as record} + + {/each} + {/if}