function createDataRequestOpts(groups, groupName) {
  const {module, package: pkg, query, input, included} = getGroupData(groups, groupName) // Throws user-friendly messages.

  try {
    const body = {} // In the format accepted by playground backend
    body.rego_modules = {[EVAL_MODULE_NAME]: module, ...included}
    body.query_package = pkg
    if (query) {
      body.rego = query
    }
    if (input) {
      body.input = input
    }

    return {
      body: JSON.stringify(body),
      // Both types of requests are POSTing JSON
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
    }
  } catch (e) { // Presumably stringifying the body failed, that shouldn't happen
    throw new ChainedError('unexpected error', e)
  }
}
// Constructs a the fetch options for querying the playground with a DataRequest. Throws an error with a user-friendly message if it can't.
Constructs a the fetch options for querying the playground with a DataRequest. Throws an error with a user-friendly message if it can't.
Constructs a the fetch options for querying the playground with a DataRequest . Throws an error with a user - friendly message if it can ' t .
function createDataRequestOpts(groups, groupName) {
  const {module, package: pkg, query, input, included} = getGroupData(groups, groupName) 
  try {
    const body = {} 
    body.rego_modules = {[EVAL_MODULE_NAME]: module, ...included}
    body.query_package = pkg
    if (query) {
      body.rego = query
    }
    if (input) {
      body.input = input
    }
    return {
      body: JSON.stringify(body),
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
    }
  } catch (e) { 
    throw new ChainedError('unexpected error', e)
  }
}
function createDataRequestOpts ( groups , groupName ) { const { module , package : pkg , query , input , included } = getGroupData ( groups , groupName ) try { const body = { } body . rego_modules = { [ EVAL_MODULE_NAME ] : module , ... included } body . query_package = pkg if ( query ) { body . rego = query } if ( input ) { body . input = input } return { body : JSON . stringify ( body ) , method : 'POST' , headers : { 'Content-Type' : 'application/json' , } , } } catch ( e ) { throw new ChainedError ( 'unexpected error' , e ) } }
Constructs a the fetch options for querying the playground with a DataRequest.
Constructs a the fetch options for querying the playground with a DataRequest .
// Throws user-friendly messages. // In the format accepted by playground backend // Both types of requests are POSTing JSON // Presumably stringifying the body failed, that shouldn't happen