src/core/service.js
function doCallEndpoint(callSpec, next, onReceive, onError, store) {
  const { method, path, urlParams, body, token, baseUrl } = callSpec
  return apiFetch(compileUrl(path, urlParams), { ...fetchOptions(method, body, token), baseUrl })
    .then(response =>
      // TODO
      // if (response.status === 401) {
      //   next(unauthorized());
      // }
      (response.ok
        ? response.json().then(json => next(transformReceiveAction(onReceive((json)), store)))
        // TODO: error parsing should be configurable globally (here we assume that a json object comes
        // with { error: { message } }
        : response.json().then(json => next(onError(json.error.message))))
    )
    .catch(error => {
      // console.error('ERROR on API Call', error)
      next(onError(error.message))
    })
}
function doCallEndpoint(callSpec, next, onReceive, onError, store) {
  const { method, path, urlParams, body, token, baseUrl } = callSpec
  return apiFetch(compileUrl(path, urlParams), { ...fetchOptions(method, body, token), baseUrl })
    .then(response =>
      // TODO
      // if (response.status === 401) {
      //   next(unauthorized());
      // }
      (response.ok
        ? response.json().then(json => next(transformReceiveAction(onReceive((json)), store)))
        // TODO: error parsing should be configurable globally (here we assume that a json object comes
        // with { error: { message } }
        : response.json().then(json => next(onError(json.error.message))))
    )
    .catch(error => {
      // console.error('ERROR on API Call', error)
      next(onError(error.message))
    })
}
function doCallEndpoint ( callSpec , next , onReceive , onError , store ) { const { method , path , urlParams , body , token , baseUrl } = callSpec return apiFetch ( compileUrl ( path , urlParams ) , { ... fetchOptions ( method , body , token ) , baseUrl } ) . then ( response => // TODO // if (response.status === 401) { //   next(unauthorized()); // } ( response . ok ? response . json ( ) . then ( json => next ( transformReceiveAction ( onReceive ( ( json ) ) , store ) ) ) // TODO: error parsing should be configurable globally (here we assume that a json object comes // with { error: { message } } : response . json ( ) . then ( json => next ( onError ( json . error . message ) ) ) ) ) . catch ( error => { // console.error('ERROR on API Call', error) next ( onError ( error . message ) ) } ) }
/* eslint-disable no-console
/ * eslint - disable no - console