-
Notifications
You must be signed in to change notification settings - Fork 151
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
Since the latest version 1.5.0 ofetch throws an error if $fetch it used in Nuxt 4.2.0.
Linked issue: nuxt/nuxt#33604 (comment)
Reproduction:
I've made small reproduction of this issue
https://stackblitz.com/edit/github-kbqwxvpo?file=app%2Fapp.vue
In App.vue file, I create new $fetch client and tries to send POST request with body and in console, you will see the error
Reproduction
<script setup lang="ts">
const httpOptions = {
baseURL: '/api',
credentials: 'include',
headers: {
Accept: 'application/json',
},
retry: false,
async onRequest({ options, request }) {
options.headers = {
Accept: 'application/json',
};
console.log(options.headers);
},
};
const client = $fetch.create(httpOptions);
const test = async () => {
console.log('SEND POST REQUEST');
client('/login', {
method: 'post',
body: {
email: 'test@mail.com',
password: '12312313',
},
});
};
</script>
<template>
<div>
<button @click="test">click</button>
</div>
</template>
<style scoped></style>This code will log a browser error: context.options.headers.get is not a function
Describe the bug
It throws the error context.options.headers.get is not a function if custom headers are set when using $fetch in a Nuxt 4.2.0 project.
Additional context
No response
Logs
kricsleo
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working