src/internals/reactools/fetch/fetchHandlers.js
/**
 * Process fetchMetadata entry and action payload to derive the url and request options for the fetch call to be made
 *
 * @param {object} entry - fetch metadata entry
 * @param {object} payload - fetch action payload
 * @return {object} url and options as an object
 */
Process fetchMetadata entry and action payload to derive the url and request options for the fetch call to be made
@param {object} entry - fetch metadata entry
@param {object} payload - fetch action payload
@return {object} url and options as an object
Process fetchMetadata entry and action payload to derive the url and request options for the fetch call to be made @param { object } entry - fetch metadata entry @param { object } payload - fetch action payload @return { object } url and options as an object
function deriveUrlAndPayload(entry, payload) {
  let { url, options } = entry;
  const optionsClone = { ...options },
    payloadClone = { ...payload },
    pathTokens = url.split('/:');
  if (url.indexOf('/:') !== 0) {
    pathTokens.shift();
  }
  pathTokens.forEach(token => {
    const paramKey = token.split('/')[0];
    url = url.replace(`/:${paramKey}`, `/${payloadClone[paramKey]}`);
    delete payloadClone[paramKey];
  });
  if (optionsClone.method === HTTP_METHODS.GET) {
    optionsClone.params = { ...payloadClone, ...optionsClone.params };
  } else {
    optionsClone.body = { ...payloadClone, ...optionsClone.body };
  }
  return {
    url,
    options: optionsClone
  };
}
function deriveUrlAndPayload ( entry , payload ) { let { url , options } = entry ; const optionsClone = { ... options } , payloadClone = { ... payload } , pathTokens = url . split ( '/:' ) ; if ( url . indexOf ( '/:' ) !== 0 ) { pathTokens . shift ( ) ; } pathTokens . forEach ( token => { const paramKey = token . split ( '/' ) [ 0 ] ; url = url . replace ( ` ${ paramKey } ` , ` ${ payloadClone [ paramKey ] } ` ) ; delete payloadClone [ paramKey ] ; } ) ; if ( optionsClone . method === HTTP_METHODS . GET ) { optionsClone . params = { ... payloadClone , ... optionsClone . params } ; } else { optionsClone . body = { ... payloadClone , ... optionsClone . body } ; } return { url , options : optionsClone } ; }
Process fetchMetadata entry and action payload to derive the url and request options for the fetch call to be made
 @param {object} entry - fetch metadata entry
 @param {object} payload - fetch action payload
 @return {object} url and options as an object
Process fetchMetadata entry and action payload to derive the url and request options for the fetch call to be made @param { object } entry - fetch metadata entry @param { object } payload - fetch action payload @return { object } url and options as an object
// Note - metadata will not be validated here expecting that the metadata file is perfect and predictable // Cloned to avoid later assigned values being persistent across requests // Cater for path parameters // Note - This code block must appear before params/body is assigned to optionsClone object // Assume that same data will not be sent as both path param and query/body