src/util.js
async function getJSON(res) {
  const contentType = res.headers.get('Content-Type');
  const emptyCodes = [204, 205];

  if (
    !~emptyCodes.indexOf(res.status) &&
    contentType &&
    ~contentType.indexOf('json')
  ) {
    return await res.json();
  } else {
    return await Promise.resolve();
  }
}
async function getJSON(res) {
  const contentType = res.headers.get('Content-Type');
  const emptyCodes = [204, 205];

  if (
    !~emptyCodes.indexOf(res.status) &&
    contentType &&
    ~contentType.indexOf('json')
  ) {
    return await res.json();
  } else {
    return await Promise.resolve();
  }
}
async function getJSON ( res ) { const contentType = res . headers . get ( 'Content-Type' ) ; const emptyCodes = [ 204 , 205 ] ; if ( ! ~ emptyCodes . indexOf ( res . status ) && contentType && ~ contentType . indexOf ( 'json' ) ) { return await res . json ( ) ; } else { return await Promise . resolve ( ) ; } }
Extract JSON body from a server response

@function getJSON
@access public
@param {object} res - A raw response object
@returns {promise|undefined}
Extract JSON body from a server response