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

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

Closed
mrauhu wants to merge 1 commit into
nuxt: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 into
nuxt:mainfrom
mrauhu:fetch-non-get-and-formdata-fix

Conversation

@mrauhu

@mrauhumrauhu commented Jun 29, 2022

Copy link
Copy Markdown
Contributor

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

Resolvesnuxt/nuxt#13839.

Example of usage after this fix is applied:

<script setup lang="ts">asyncfunction formSubmit(event:Event& { target:HTMLFormElement }) {const body =newFormData(event.target);awaituseFetch('/', { method: 'POST',body, });}</script>
<template>
<formid="example-form"method="post"@submit.prevent="formSubmit">
<buttontype="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

netlifyBot commented Jun 29, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit94effb6
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62bc68900dc9000008bd5d10

@pi0pi0 mentioned this pull request Jul 6, 2022
@pi0

pi0 commented Jul 7, 2022

Copy link
Copy Markdown
Member

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

@mrauhu@pi0@danielroe