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

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

Closed
wants to merge 1 commit into from

Conversation

mrauhu
Copy link
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

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
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