1 import { environment } from '../../../environments/environment'
3 function getAbsoluteAPIUrl () {
4 let absoluteAPIUrl = environment.hmr === true
5 ? 'http://localhost:9000'
9 // The API is on the same domain
10 absoluteAPIUrl = window.location.origin
16 function getAPIHost () {
17 return new URL(getAbsoluteAPIUrl()).host
20 function getAbsoluteEmbedUrl () {
21 let absoluteEmbedUrl = environment.originServerUrl
22 if (!absoluteEmbedUrl) {
23 // The Embed is on the same domain
24 absoluteEmbedUrl = window.location.origin
27 return absoluteEmbedUrl
30 // Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
31 function objectToFormData (obj: any, form?: FormData, namespace?: string) {
32 const fd = form || new FormData()
35 for (const key of Object.keys(obj)) {
36 if (namespace) formKey = `${namespace}[${key}]`
39 if (obj[key] === undefined) continue
41 if (Array.isArray(obj[key]) && obj[key].length === 0) {
46 if (obj[key] !== null && typeof obj[key] === 'object' && !(obj[key] instanceof File)) {
47 objectToFormData(obj[key], fd, formKey)
49 fd.append(formKey, obj[key])