Menu

Give the agent the existing session helper, don’t invent a new fetch to /me in the page
📰

Give the agent the existing session helper, don’t invent a new fetch to /me in the page

DEV Community: frontend·Sherotree·8 days ago
#8QjwSHFW
#devtofrontend#devto#dev#helper#user
Long article (470 words) — no AI summary yet.
Reading 0:00
15s threshold

The PR needs the current user and adds fetch('/api/me') , a new useCurrentUser hook, or a raw localStorage.getItem('token') read in the page. The repo already has a session helper ( getSession , useAuth , or useSession ) that the rest of the UI uses for the signed-in user, loading, and signed-out states. The new call looks fine in isolation and then disagrees with the header, expires the token differently, or skips the existing error path.

I've started treating a one-off /me fetch in a feature page as a consistency bug , not as a quicker read. The helper is there so every screen does not invent its own idea of "who is signed in." This article was written with the assistance of AI.

Why the homemade session read shows up

Auth tutorials start with fetch('/me') or a token in localStorage . The model can write that without finding useAuth .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.