-
Notifications
You must be signed in to change notification settings - Fork 289
Failed to execute 'atob' on 'Window' #92
Comments
function urlB64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}
return outputArray;
} make sure you
|
I have the same issue in @firebase/messaging library. I don't know how to fix that. index.esm.js?8071:131 --- INSIDE THE LIBRARY --- function base64ToArray(base64String) { |
@nintcheu This codelab does not use Firebase. You can find a Firebase Cloud Messaging example here. As the error says, the string is not correctly encoded. Unfortunately, I cannot help you further here. I recommend that you look at the Firebase Cloud Messaging example and ask for help in the firebase/quickstart-js repository. |
Hi! I'm getting the following error on my console that's preventing me from enabling the push notifications:
main.js:37 Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at urlB64ToUint8Array (http://127.0.0.1:8887/scripts/main.js:37:26)
at subscribeUser (http://127.0.0.1:8887/scripts/main.js:116:32)
at HTMLButtonElement. (http://127.0.0.1:8887/scripts/main.js:69:7)
urlB64ToUint8Array @ main.js:37
It's the line const rawData = window.atob(base64);
that's in the function provided in main.js
function urlB64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/-/g, '+')
.replace(/_/g, '/');
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}
return outputArray;
}
I am new to this and have no clue what is going on. Any help/clarification would be GREATLY appreciated. Thanks!
The text was updated successfully, but these errors were encountered: