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 getAbsoluteEmbedUrl () {
17 let absoluteEmbedUrl = environment.originServerUrl
18 if (!absoluteEmbedUrl) {
19 // The Embed is on the same domain
20 absoluteEmbedUrl = window.location.origin
23 return absoluteEmbedUrl
26 // Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
27 function objectToFormData (obj: any, form?: FormData, namespace?: string) {
28 const fd = form || new FormData()
31 for (const key of Object.keys(obj)) {
32 if (namespace) formKey = `${namespace}[${key}]`
35 if (obj[key] === undefined) continue
37 if (Array.isArray(obj[key]) && obj[key].length === 0) {
42 if (obj[key] !== null && typeof obj[key] === 'object' && !(obj[key] instanceof File)) {
43 objectToFormData(obj[key], fd, formKey)
45 fd.append(formKey, obj[key])