function requestWithPayload(requestObject) {
  if (!requestObject) {
    throw new Error('Cannot post/patch without form object.');
  }
  const { url, verb, formObj } = requestObject;
  return new Promise((resolve, reject) => {
    superagent(verb, API_URL + url)
    .set('Content-Type', 'application/json')
    .send(JSON.stringify(formObj))
    .end((error, response) => {
      error ? reject(error) : resolve(response.body);
    });
  });
}
/**
 * POSTS/PATCHES the resource, with the specified object
 *
 * @param {Object} requestObject The object with url, HTTP verb, and formObject
 * @returns {Promise} If successful, the promise wraps the returned resource(s).
 * Else the error handler gets the error.
 */
POSTS/PATCHES the resource, with the specified object
@param {Object} requestObject The object with url, HTTP verb, and formObject
@returns {Promise} If successful, the promise wraps the returned resource(s).
Else the error handler gets the error.
POSTS / PATCHES the resource with the specified object @param { Object } requestObject The object with url HTTP verb and formObject @returns { Promise } If successful the promise wraps the returned resource ( s ) . Else the error handler gets the error .
function requestWithPayload(requestObject) {
  if (!requestObject) {
    throw new Error('Cannot post/patch without form object.');
  }
  const { url, verb, formObj } = requestObject;
  return new Promise((resolve, reject) => {
    superagent(verb, API_URL + url)
    .set('Content-Type', 'application/json')
    .send(JSON.stringify(formObj))
    .end((error, response) => {
      error ? reject(error) : resolve(response.body);
    });
  });
}
function requestWithPayload ( requestObject ) { if ( ! requestObject ) { throw new Error ( 'Cannot post/patch without form object.' ) ; } const { url , verb , formObj } = requestObject ; return new Promise ( ( resolve , reject ) => { superagent ( verb , API_URL + url ) . set ( 'Content-Type' , 'application/json' ) . send ( JSON . stringify ( formObj ) ) . end ( ( error , response ) => { error ? reject ( error ) : resolve ( response . body ) ; } ) ; } ) ; }
POSTS/PATCHES the resource, with the specified object
 @param {Object} requestObject The object with url, HTTP verb, and formObject
 @returns {Promise} If successful, the promise wraps the returned resource(s).
POSTS / PATCHES the resource with the specified object @param { Object } requestObject The object with url HTTP verb and formObject @returns { Promise } If successful the promise wraps the returned resource ( s ) .