# kivra-copy-consumer

> Allows a service to consume Kivra copy

Latest version **1.0.3** (published 2018-11-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install kivra-copy-consumer
pnpm add kivra-copy-consumer
yarn add kivra-copy-consumer
bun add kivra-copy-consumer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2018-11-01 |
| First published | 2018-10-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 26.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | dev@kivra.com |
| Maintainers | biggestt, kivra-dev, lambdalainen, samiralajmovic, timjackleus |

## Links

- npm: https://www.npmjs.com/package/kivra-copy-consumer
- Repository: https://github.com/kivra/kivra_copy_consumer
- Homepage: https://github.com/kivra/kivra_copy_consumer#readme
- Issues: https://github.com/kivra/kivra_copy_consumer/issues
- npm.io page: https://npm.io/package/kivra-copy-consumer

## Dependencies (3)

- [querystring](https://npm.io/package/querystring.md) ^0.2.0
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.0.0
- [karma-phantomjs-launcher](https://npm.io/package/karma-phantomjs-launcher.md) ^1.0.4

## Recent versions

- 1.0.3 (latest) — 2018-11-01
- 1.0.1 — 2018-10-18
- 1.0.0 — 2018-10-18

## README

## Kivra copy consumer

Reusable copy consumption logic for Kivra frontend services

## Get started
```
npm i --save kivra-copy-consumer
```

```javascript
import { fetchCopy } from 'kivra-copy-consumer'

fetchCopy({
  'en-US': 'https://example.com/us-copy.json'
},
{
  useBrowserLocale: true,
  fallbackLocale: 'en-US',
  defaultCopyPath: '/copy-default.json'
}).then(copy => {
  // use copy ...
})
```
### Which locale is used?
In order of prioritization:
- if `locale` GET param is set in URL, copy is fetched for that locale
- if `useBrowserLocale` is `true`, use locale prefered by browser
- otherwise use `fallbackLocale`

### Which file is fetched
- If an url for the chosen locale was passed then that is fetched. If the fetch fails we instead fetch `defaultCopyPath`.
- If no url for the chosen locale was passed then the url for `fallbackLocale` is fetched

---
_Source: https://npm.io/package/kivra-copy-consumer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
