JSFiddle - React, Tailwind, and code Playground

by Julien Etienne

JavaScript

const aquire = (target, ...sources) => {
    const sourcesLength = sources.length;
    for (let i = 0; i < sourcesLength; i++) {
        const source = sources[i];
        if (typeof source === 'object' || typeof source === 'string') {
            const keys = Object.keys(source);
            const keysLength = keys.length;
            for (let j = 0; j < keysLength; j++) {
                const key = keys[j];
                target[key] = source[key];
            }
        } else {
            return target;
        }
    }
    return target;
}

const defaults = {
	method: 'GET',
  headers: ,
  body: null,
  mode: 'no-cors'. 				// Limits method to HEAD | GET | POST
  credentials: 'omit',		// Does not send cookies
  cache: 'default',  			// Looks for matching request in the HTTP cache 
  redirect: 'follow',     // @todo this may need to be disabled for security
  referrer: 'client',
  referrerPolicy: 'no-referrer-when-downgrading',
  // integrity						// To be discussed 
  keepalive: false, 			// Set to true replaces sendBeacon API
  signal:                // To abort a pending request (all modern browsers supported)
  
}


const a = aquire(defaults, init);

console.log('a',a)