I'm using the npm package node-redis version 3.1.0 and I've included the following in my .vue file, specifically in the <script></script> block:
import { createClient } from 'redis';
Inside methods for export default, I have the following:
async getVal(redisKey) {
const client = createClient();
// eslint-disable-next-line
client.on('error', (err) => console.log('Redis Client Error', err));
await client.connect();
const value = await client.get(redisKey);
return value;
},
The code compiles with no errors, but when I launch my site in the browser, I get the following error in my browser console:
index.js:3 Uncaught TypeError: Cannot read properties of undefined (reading 'charCodeAt')
at Object.<anonymous> (index.js:3)
at Object.f3c2 (chunk-vendors.bcef36a0.js:73)
at i (bootstrap:79)
at Object.b620 (customErrors.js:5)
at i (bootstrap:79)
at Object.<anonymous> (index.js:9)
at Object.a111 (chunk-vendors.bcef36a0.js:41)
at i (bootstrap:79)
at Module.56d7 (app.05cc1827.js:1)
at i (bootstrap:79)
(anonymous) @ index.js:3
f3c2 @ chunk-vendors.bcef36a0.js:73
i @ bootstrap:79
b620 @ customErrors.js:5
i @ bootstrap:79
(anonymous) @ index.js:9
a111 @ chunk-vendors.bcef36a0.js:41
i @ bootstrap:79
56d7 @ app.05cc1827.js:1
i @ bootstrap:79
0 @ app.05cc1827.js:1
i @ bootstrap:79
a @ bootstrap:45
(anonymous) @ bootstrap:152
(anonymous) @ app.05cc1827.js:1
index.js:
'use strict'
const Errors = process.version.charCodeAt(1) < 55 && process.version.charCodeAt(2) === 46
? require('./lib/old') // Node.js < 7
: require('./lib/modern')
module.exports = Errors
How do I fix this? I don't understand what I'm doing wrong that would cause this error.