I have data like this, as we can see, the receiving type in redis is string, but I made it look like a JSON file.
enter image description here
We need to get all title
and jobTitile
and output them here. It’s better, of course, to do this through the .map
function. I’m using TypeScript – 5.2.2v and Next.js – 13.5.4v:
import React from "react";
import {Redis} from "@upstash/redis";
const redis = Redis.fromEnv();
const data: any = redis.get("foo");
export const revalidate = 0
export default function ProjectsPage() {
return (
<div className="flex flex-col items-center w-screen h-screen bg-gradient-to-tl from-black via-zinc-600/20 to-black">
<div className="w-[460px] m-6 md:m-20 animate-fade-in">
<div>
<h1 className="mt-10 text-sm text-neutral-400 mb-2 lowercase">
{data.map(items => {
return (
<>{items.title} and {items.jobTitle}</>
)
})}
</h1>
</div>
</div>
</div>
);
}
I have been, but nothing works out for me, there are always some mistakes.
And just to make it easier for you, I will give you the code from my Redies database
UPSTASH_REDIS_REST_URL=https://harmless-monster-55347.upstash.io
UPSTASH_REDIS_REST_TOKEN=AdgzAAIncDEzMDQ5ZTVhODQ1Y2M0NGEyOWVkNjA2N2UzYzUwNGZiZXAxNTUzNDc
I tried to receive and parse in JSON, but nothing worked, I thought about making an object and nothing worked either
Devollox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.