Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): allow usage of useFetch() function with FormData#5661

Closed
mrauhu wants to merge 1 commit intonuxt:mainfrom
mrauhu:fetch-non-get-and-formdata-fix
Closed

fix(nuxt): allow usage of useFetch() function with FormData#5661
mrauhu wants to merge 1 commit intonuxt:mainfrom
mrauhu:fetch-non-get-and-formdata-fix

Conversation

@mrauhu
Copy link
Copy Markdown
Contributor

@mrauhu mrauhu commented Jun 29, 2022

Hello.

🔗 Linked issue

nuxt/nuxt#13839

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Resolves nuxt/nuxt#13839.

Example of usage after this fix is applied:

<script setup lang="ts">
async function formSubmit(event: Event & { target: HTMLFormElement }) {
  const body = new FormData(event.target);

  await useFetch('/', {
    method: 'POST',
    body,
  });
}
</script>

<template>
  <form id="example-form" method="post" @submit.prevent="formSubmit">
    <button type="submit">Send</button>
  </form>
</template>

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Best wishes,
Sergey.

…function call that can't recognize `FormData` as valid object.

Disable initial cache for payload (non-GET) methods when using `useFetch()` function.
@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 29, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit 94effb6
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62bc68900dc9000008bd5d10

@pi0 pi0 mentioned this pull request Jul 6, 2022
@pi0
Copy link
Copy Markdown
Member

pi0 commented Jul 7, 2022

Thanks for the PR <3 With #4955, we no longer use hash function in useFetch although I also made upstream issue (unjs/ohash#10) to track this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$fetch is broken on post FormData

3 participants