#Trying to display page views with redis

39 messages · Page 1 of 1 (latest)

normal sail
#

"Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."

I keep getting this error and then in my console getting an error with api/view/route on not being found.

tranquil pendantBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

grim gull
#

i don't think you can just export handler like that...

normal sail
#

Thx for replying, refactored it to separate the GET and POST methods into different functions, still getting the same error

grim gull
#

you request it as POST or GET /api/view (no /route is needed)

#

also, im assuming you don't want it to increment on the footer, and just show the amount of views

torn pendant
#

@normal sail write return before res.json or res.status

grim gull
#

yeah make sure to use nextjs response

import { NextResponse } from 'next/server'
 
export async function GET() {
  return NextResponse.json({ hello : "world"})
}
normal sail
torn pendant
#

@normal sail also use phind.com it will be way faster in helping

grim gull
#

pls don't recommend AI, if you want to, at least use #1089389297548931182 because nextjs team trusts it and makes sure its trained on latest docs

normal sail
#

Yes I've been using cursor.so with the latest nextjs 13 docs

#

Thx for the suggestion @torn pendant

torn pendant
#

Phind pulls lastest docs, doesn't usually hallucinate

normal sail
#

I'll check it out, let me modify it with the nextjs response first

#

I'm not getting any errors but the views aren't updating at every refresh

grim gull
#

where are you running the post req?

torn pendant
#

Add console logs to see what code gets executed

#

In both methods

grim gull
#

the code provided in second screenshot only shows them using get request, so im wondering where it gets incremented

torn pendant
#

Also is redis locally hosted? You can't do that with a edge function. Try using a service that hosts a redis instance for you

normal sail
grim gull
#

can we also pls not assume more than nessary... not all devs want to use vercel... a decent amount want to self host, where redis is good + they could be connecting to serverless redis host anyway

normal sail
#

Should I deploy it? I'm using upstash redis and it's showing in the dashboard that it's reading

grim gull
#

i still don't see wher you are either calling the post req ore incremening it server side

normal sail
#

Ok so that's probably the issue that the Post request to increment the views is not called anywhere

grim gull
#

yeah

normal sail
#

Ahhhhhhhh

#

thank you so much

#

Sorry for the questions transitioning from design to dev

#

It's working 🙏

grim gull
#

yay!

torn pendant
grim gull
#

lol i didn't even relise that it was an ai product...

normal sail
#

Lol nah getting some help from a friend

#

Mainly doing front-end/ux/sales

#

But trying to help where I can