1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-09 21:30:05 +00:00

fix: new axios requires form data content type, es6 strict issues with iterations

This commit is contained in:
2025-03-07 10:36:43 +01:00
parent 008a9b4ca5
commit 4fb0b96f11
12 changed files with 478 additions and 374 deletions

View File

@@ -1,5 +1,5 @@
import { isNode } from './'
import NodeFormData from 'form-data'
export const getFormData = () =>
export const getFormData = (): NodeFormData | FormData =>
isNode() ? new NodeFormData() : new FormData()

View File

@@ -52,19 +52,22 @@ export const validateInput = (
}
}
for (const item of data[key]) {
if (getType(item) !== 'object') {
return {
status: false,
msg: `Table ${key} contains invalid structure. ${MORE_INFO}`
}
} else {
const attributes = Object.keys(item)
for (const attribute of attributes) {
if (item[attribute] === undefined) {
return {
status: false,
msg: `A row in table ${key} contains invalid value. Can't assign undefined to ${attribute}.`
// ES6 is stricter so we had to include the check for the array
if (Array.isArray(data[key])) {
for (const item of data[key]) {
if (getType(item) !== 'object') {
return {
status: false,
msg: `Table ${key} contains invalid structure. ${MORE_INFO}`
}
} else {
const attributes = Object.keys(item)
for (const attribute of attributes) {
if (item[attribute] === undefined) {
return {
status: false,
msg: `A row in table ${key} contains invalid value. Can't assign undefined to ${attribute}.`
}
}
}
}