DOM utils for E-Com Plus admin and related frontend apps
npm i @ecomplus/admin-helpers
import { i19savedWithSuccess } from '@ecomplus/i18n'
import { i18n } from '@ecomplus/utils'
import ecomAuth from '@ecomplus/auth'
import { toast, handleApiError } from '@ecomplus/admin-helpers'
ecomAuth.login(localStorage.getItem('username'), localStorage.getItem('password'))
ecomAuth.on('login', () => {
ecomAuth.requestApi('stores/me', 'patch', {
domain: 'www.mystoredomain.com'
})
.then(() => toast(i18n(i19savedWithSuccess)))
.catch(handleApiError)
})
<script src="https://cdn.jsdelivr.net/npm/@ecomplus/admin-helpers/dist/toast.var.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@ecomplus/admin-helpers/dist/handle-api-error.var.min.js"></script>
window.toast('Hello!')
It uses jQuery and Bootstrap 4 scripts (toast only).