diff --git a/packages/builder/src/components/nav/ModelNavigator/TableDataImport.svelte b/packages/builder/src/components/nav/ModelNavigator/TableDataImport.svelte index 9bdaf7e77d..8e6b184755 100644 --- a/packages/builder/src/components/nav/ModelNavigator/TableDataImport.svelte +++ b/packages/builder/src/components/nav/ModelNavigator/TableDataImport.svelte @@ -2,6 +2,7 @@ import { Heading, Body, Button, Select } from "@budibase/bbui" import { notifier } from "builderStore/store/notifications" import { FIELDS } from "constants/backend" + import api from "builderStore/api" const BYTES_IN_KB = 1000 const BYTES_IN_MB = 1000000 @@ -28,6 +29,9 @@ const modelSchema = {} for (let key in schema) { const type = schema[key].type + + if (type === "omit") continue + modelSchema[key] = { name: key, type, @@ -38,16 +42,9 @@ } async function validateCSV() { - const response = await fetch("/api/models/csv/validate", { - method: "POST", - body: JSON.stringify({ - file: files[0], - schema: schema || {}, - }), - headers: { - "Content-Type": "application/json", - Accept: "application/json", - }, + const response = await api.post("/api/models/csv/validate", { + file: files[0], + schema: schema || {}, }) parseResult = await response.json() @@ -79,8 +76,9 @@ await validateCSV() } - function omitColumn(columnName) { - parsers[columnName] = PARSERS.omit + async function omitColumn(columnName) { + schema[columnName].type = "omit" + await validateCSV() } const handleTypeChange = column => evt => { @@ -97,7 +95,7 @@