Skip to content

Commit 4b5e12f

Browse files
authored
Update console.js to run in enviroments without console
I tried to run this component on NUXT SSR but it could not be served by Cloudflare because in that context the console is not reachable so an easy fix is just to provide an empty stub object
1 parent 8687d34 commit 4b5e12f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util/console.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function getConsole() {
2-
if (typeof window !== "undefined") {
3-
return window.console;
4-
}
5-
return global.console;
2+
if (typeof window !== "undefined" && window.console) return window.console;
3+
if (global && global.console) return global.console;
4+
return { log: function () { }, warn: function () { }, error: function () { }, info: function () { } }
65
}
6+
77
const console = getConsole();
88

99
export { console };

0 commit comments

Comments
 (0)