kivra-copy-consumer
v1.0.3
Published
Allows a service to consume Kivra copy
Downloads
1
Keywords
Readme
Kivra copy consumer
Reusable copy consumption logic for Kivra frontend services
Get started
npm i --save kivra-copy-consumer
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
istrue
, 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