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

feat(nuxt): allow passing custom fetch options to useFetch - #5660

Merged
pi0 merged 1 commit into
nuxt:mainfrom
mrauhu:fetch-async-data-options
Jul 6, 2022
Merged

feat(nuxt): allow passing custom fetch options to useFetch#5660
pi0 merged 1 commit into
nuxt:mainfrom
mrauhu:fetch-async-data-options

Conversation

@mrauhu

@mrauhumrauhu commented Jun 29, 2022

Copy link
Copy Markdown
Contributor

Hello.

🔗 Linked issue

unjs/destr#9

❓ 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

This fix needed to provide custom $fetch() options, like a providing custom parseResponse() function to fix the memory leak caused by destr() function:

importtype{FetchOptions}from'ohmyfetch';/** * Parse response * @description Replace of `destr()` function to prevent memory leak * @param responseText */constparseResponse: FetchOptions['parseResponse']=(responseText)=>{// Send empty string if zero lengthif(responseText.length===0){return'';}try{returnJSON.parse(responseText);}catch(_e){returnresponseText;}};// Example of usageuseFetch('/',{
parseResponse,};

📝 Checklist

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

Best wishes,
Sergey.

…ch()` options and `useAsyncData()` options.
This needed to provide custom options for the `$fetch()` function.
@netlify

netlifyBot commented Jun 29, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

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

@mrauhumrauhu changed the title fix(nuxt): Allow providing custom $fetch() options via an options argument of the useFetch() functionfix(nuxt): allow providing custom $fetch() options via an options argument of the useFetch() functionJun 29, 2022
pi0
pi0 approved these changes Jul 6, 2022
@pi0pi0 changed the title fix(nuxt): allow providing custom $fetch() options via an options argument of the useFetch() functionfeat(nuxt): allow passing custom fetch options to useFetchJul 6, 2022
@pi0
pi0 merged commit 93d60a3 into nuxt:mainJul 6, 2022
@pi0

pi0 commented Jul 6, 2022

Copy link
Copy Markdown
Member

Thanks!

pi0 added a commit that referenced this pull request Jul 6, 2022
@pi0pi0 mentioned this pull request Jul 11, 2022
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.

3 participants

@mrauhu@pi0@danielroe