skapi-js
Advanced tools
Comparing version 1.0.98-beta.1 to 1.0.99-beta.0
@@ -28,3 +28,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
constructor(service, owner, options, __etc) { | ||
this.version = '1.0.98'; | ||
this.version = '1.0.99'; | ||
this.session = null; | ||
@@ -31,0 +31,0 @@ this.connection = null; |
import SkapiError from '../main/error'; | ||
import validator from './validator'; | ||
import { MD5, generateRandom } from './utils'; | ||
import { MD5, generateRandom, extractFormData } from './utils'; | ||
async function getEndpoint(dest, auth) { | ||
@@ -23,3 +23,2 @@ const endpoints = await Promise.all([ | ||
case 'subscribe-public-newsletter': | ||
case 'signup': | ||
case 'admin-signup': | ||
@@ -121,22 +120,7 @@ case 'confirm-signup': | ||
Object.assign(required, fetchOptions); | ||
if (data instanceof SubmitEvent) { | ||
data = data?.target; | ||
} | ||
if (data instanceof HTMLFormElement) { | ||
data = new FormData(data); | ||
} | ||
let isForm = (data instanceof FormData); | ||
data = extractFormData(data).data; | ||
if (!data) { | ||
data = required; | ||
} | ||
else if (isForm) { | ||
for (let k in required) { | ||
if (required[k] !== undefined) { | ||
data.set(k, new Blob([JSON.stringify(required[k])], { | ||
type: 'application/json' | ||
})); | ||
} | ||
} | ||
} | ||
else { | ||
else if (data && typeof data === 'object') { | ||
data = Object.assign(required, data); | ||
@@ -181,3 +165,3 @@ } | ||
'Accept': '*/*', | ||
"Content-Type": options?.contentType || (data instanceof FormData) ? 'multipart/form-data' : 'application/json' | ||
"Content-Type": options?.contentType || 'application/json' | ||
}; | ||
@@ -222,3 +206,3 @@ if (token) { | ||
else { | ||
opt.body = data instanceof FormData ? data : data ? JSON.stringify(data) : null; | ||
opt.body = data ? JSON.stringify(data) : null; | ||
} | ||
@@ -225,0 +209,0 @@ opt.method = method; |
{ | ||
"name": "skapi-js", | ||
"version": "1.0.98-beta.1", | ||
"version": "1.0.99-beta.0", | ||
"description": "Skapi: Backend API for HTML frontend.", | ||
@@ -5,0 +5,0 @@ "main": "dist/skapi.module.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2037575
6419