Fetch

Monster.I18n.Providers. Fetch

The fetch provider retrieves a JSON file from the given URL and returns a translation object.

You can create the object via the monster namespace new Monster.I18n.Provider.Fetch().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/i18n/providers/fetch.js';
console.log(new Monster.I18n.Providers.Fetch())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {Fetch} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/i18n/providers/fetch.js';
console.log(new Fetch())
</script>

Constructor

# new Fetch(url, options)

As options the key fetch can be passed. This config object is passed to the fetch method as init.

Parameters:
Name Type Description
url string | URL
options Object

see Monster.I18n.Providers.Fetch#defaults

Since:
  • 1.13.0

Members

# defaults

Defaults

Properties
Name Type Description
fetch Object
Properties
Name Type Default Description
method String GET
mode String cors
cache String no-cache
credentials String omit
redirect String follow
referrerPolicy String no-referrer

# url

Properties
Type Description
string

Methods

# getTranslations(locale) → {Promise}

Parameters:
Name Type Description
locale Locale | string
Returns:
Type
Promise