How to use the @redux-offline/redux-offline/lib/defaults/effect function in @redux-offline/redux-offline

To help you get started, we’ve selected a few @redux-offline/redux-offline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forest-watcher / forest-watcher / app / offline / effect.js View on Github external
export default function effect({ url, headers, errorCode, deserialize = true, ...params }, { auth, ...action }) {
  if (url && typeof url === 'string') {
    const req = {
      ...params,
      url,
      headers: { ...headers, Authorization: `Bearer ${auth}` }
    };
    const canDeserialize = res => res && typeof res === 'object' && res.data && deserialize;
    return defaultEffect(req, action)
      .then(data => (canDeserialize(data) ? new JSONAPIDeserializer(deserializeOptions).deserialize(data) : data))
      .catch(err => {
        if (errorCode) return Promise.reject({ msg: err, status: errorCode });
        throw err;
      });
  }

  throw new TypeError();
}

@redux-offline/redux-offline

Redux Offline-First Architecture

MIT
Latest version published 5 years ago

Package Health Score

59 / 100
Full package analysis

Similar packages