Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userid no longer available in request.context #1341

Closed
tobi-or-not-tobi opened this issue May 5, 2021 · 0 comments · Fixed by #1344
Closed

userid no longer available in request.context #1341

tobi-or-not-tobi opened this issue May 5, 2021 · 0 comments · Fixed by #1344

Comments

@tobi-or-not-tobi
Copy link

Describe the bug
When creating a fresh new svelte kit app, following https://kit.svelte.dev/docs#introduction-getting-started, the TODO page is not working in the newly generated app.

Logs

stack trace (In page) ```ts SyntaxError: Unexpected token T in JSON at position 0 ```
stack trace (terminal) ```shell Cannot read property 'userid' of undefined TypeError: Cannot read property 'userid' of undefined at get (/Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/src/routes/todos/index.json.ts:4:86) at render_route (file:///Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/node_modules/@sveltejs/kit/dist/ssr.js:1220:26) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async render (file:///Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/node_modules/@sveltejs/kit/dist/ssr.js:1476:10) at async Object.handle (/Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/src/hooks.ts:14:24) at async respond (file:///Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/node_modules/@sveltejs/kit/dist/ssr.js:1450:10) at async fetch (file:///Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/node_modules/@sveltejs/kit/dist/ssr.js:703:24) Unexpected token T in JSON at position 0 SyntaxError: Unexpected token T in JSON at position 0 at JSON.parse () at Proxy. (file:///Users/I303733/Documents/GitHub/sandbox/sveltekit/my-app/node_modules/@sveltejs/kit/dist/ssr.js:762:22) at processTicksAndRejections (internal/process/task_queues.js:97:5) ```

To Reproduce

  • svelte kit version: next
  • svelte version: ^3.34.0
  • app template: SvelteKit demo app
  • TypeScript: Yes
  • ESLint: Yes
  • Prettier: Yes

Expected behavior
A working TODO page.

Information about your SvelteKit Installation:

Diagnostics
  System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 4.46 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.18.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 7.6.3 - ~/.npm/bin/npm
  Browsers:
    Brave Browser: 89.1.22.71
    Chrome: 90.0.4430.93
    Firefox: 87.0
    Safari: 14.0.3
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.99 
    svelte: ^3.34.0 => 3.38.2 
    vite: ^2.1.0 => 2.2.4 
  • Your browser: chrome/macos
  • Your adapter: n/a

Severity
Just anonying for starters, easy to fix.

Additional context

  • The typescript code seems outdated, using the request.context.userid in a few places. This seems to be renamed to request.locals.userid.
  • the inline comment // request.context.userid comes from src/hooks.js could also be reworded as it's a typescript file in this context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant