While running redis when is try to get data it showing this kind of errors what is wrong with this.
(node:12362) UnhandledPromiseRejectionWarning: ReferenceError: queueMicrotask is not defined
at RedisSocket.cork (/home/aathilingam/Desktop/Laravel - Docker/rediscache/node_modules/@node-redis/client/dist/lib/client/socket.js:86:13)
at Commander._RedisClient_tick (/home/aathilingam/Desktop/Laravel - Docker/rediscache/node_modules/@node-redis/client/dist/lib/client/index.js:410:60)
at RedisSocket.socket_1.default.on.on.on.on (/home/aathilingam/Desktop/Laravel - Docker/rediscache/node_modules/@node-redis/client/dist/lib/client/index.js:331:86)
at RedisSocket.emit (events.js:198:13)
at RedisSocket._RedisSocket_connect (/home/aathilingam/Desktop/Laravel - Docker/rediscache/node_modules/@node-redis/client/dist/lib/client/socket.js:136:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:12362) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12362) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My code is for getting details of photos from a site as a json and when i try to load them into redis i got the above error. My code is
const express = require("express");
const axios = require("axios");
const cors = require("cors");
const Redis = require("redis");
//const redisClient = Redis.createClient();
const DEFAULT_EXPIRATION = 3600
const app = express();
app.use(express.urlencoded({ extended: true}));
app.use(cors());
let redisClient;
(async () => {
redisClient = Redis.createClient();
redisClient.on('error', (err) => console.log('Redis Client Error', err));
await redisClient.connect();
})();
app.get("/photos",async(req,res) => {
const albumId = req.query.albumId;
// redisClient.get(`photos?albumId=${albumId}`,async (error, photos) => {
// if(error) console.error(error)
// if(photos != null){
// console.log("cache hit");
// return res.json(JSON.parse(photos))
// }else {
console.log("cache miss");
const { data } = await axios.get(
"https://jsonplaceholder.typicode.com/photos",
{ params : { albumId } }
)
redisClient.SETEX('photos', DEFAULT_EXPIRATION, JSON.stringify(data));
// }
res.json(data);
})
//})
app.get("/photos/:id",async(req,res) => {
const { data } = await axios.get(
`https://jsonplaceholder.typicode.com/photos/${req.params.id}`
)
res.json(data);
})
console.log("listening");
app.listen(3000);
if i delete this line its working but can't do nothing without this line. help me with this.