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

fetch in next.83 errors with: Cannot read property 'split' of undefined #1133

Closed
vinkodlak opened this issue Apr 19, 2021 · 2 comments
Closed

Comments

@vinkodlak
Copy link

i get this error:

500
Cannot read property 'split' of undefined

TypeError: Cannot read property 'split' of undefined
at parse_body (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:1330:60)
at ssr (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:1448:9)
at fetch (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:697:30)
at load (index.svelte:3:27)
at load_node (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:784:30)
at respond (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:1006:21)
at async render_page (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:1154:20)
at async render (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:1467:10)
at async ssr (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/ssr.js:1454:10)
at async Immediate. (file:///Users/vinkov/svelte/novo/node_modules/@sveltejs/kit/dist/chunks/index.js:3297:23)

with this simple code:

<script context="module">
  export async function load({fetch}) {
    const res = await fetch('/server', {
      method: 'POST',
      body: {}
    })

    const { name } = await res.json()

    return {
      props: {
        name
      }
    }
  }
</script>
<script>
  export let name
</script>

<h1>{name}, Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>

when body is null or '' is works fine
if i put JSON.stringify({...}) there is same error

server.js is simple as this:

export async function post() {
  return {
    body: {
      name: 'My Name'
    }
  }
}
@vinkodlak
Copy link
Author

reverting to 80 works, breaks with 81

@Conduitry
Copy link
Member

Duplicate of #1127.

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

No branches or pull requests

2 participants