N
Nuxt7mo ago
Fisher

useFetch with patch method is making GET requests instead

Hello, I am trying to make a patch request to an endpoint on a different server. When making the request, I am getting a 405 on the external server that the GET method being sent is not allowed. So it seems that nuxt is not respecting my patch parameter as the method. Any ideas how to make a patch request/fix this issue?
const { data: application, refresh } = await useFetch<DeveloperApplicationDto>(`${config.public.abandonAuthUrl}/developer_application/${application_id}`, {
lazy: true,
headers: {
Authorization: `Bearer ${auth.value}`
}
})

async function submitNewCallbackUris() {
if (application.value?.callback_uris !== undefined){
await useFetch(`${config.public.abandonAuthUrl}/developer_application/${application_id}/callback_uris`), {
method: "PATCH",
headers: {
Authorization: `Bearer ${auth.value}`
},
body: application.value.callback_uris
}
console.log("submitted new uris")
}
}
const { data: application, refresh } = await useFetch<DeveloperApplicationDto>(`${config.public.abandonAuthUrl}/developer_application/${application_id}`, {
lazy: true,
headers: {
Authorization: `Bearer ${auth.value}`
}
})

async function submitNewCallbackUris() {
if (application.value?.callback_uris !== undefined){
await useFetch(`${config.public.abandonAuthUrl}/developer_application/${application_id}/callback_uris`), {
method: "PATCH",
headers: {
Authorization: `Bearer ${auth.value}`
},
body: application.value.callback_uris
}
console.log("submitted new uris")
}
}
1 Reply
Fisher
FisherOP7mo ago
Ha, issue was a misplaced parenthesis causing the request to send without any options I guess
const { data: application, refresh } = await useFetch<DeveloperApplicationDto>(`${config.public.abandonAuthUrl}/developer_application/${application_id}`, {
lazy: true,
headers: {
Authorization: `Bearer ${auth.value}`
}
})

async function submitNewCallbackUris() {
console.log()
if (application.value?.callback_uris !== undefined){
await useFetch<any>(`${config.public.abandonAuthUrl}/developer_application/${application_id}/callback_uris`, {
method: "patch",
headers: {
Authorization: `Bearer ${auth.value}`
},
body: application.value.callback_uris,
server: false
})
console.log("submitted new uris")
}
}
const { data: application, refresh } = await useFetch<DeveloperApplicationDto>(`${config.public.abandonAuthUrl}/developer_application/${application_id}`, {
lazy: true,
headers: {
Authorization: `Bearer ${auth.value}`
}
})

async function submitNewCallbackUris() {
console.log()
if (application.value?.callback_uris !== undefined){
await useFetch<any>(`${config.public.abandonAuthUrl}/developer_application/${application_id}/callback_uris`, {
method: "patch",
headers: {
Authorization: `Bearer ${auth.value}`
},
body: application.value.callback_uris,
server: false
})
console.log("submitted new uris")
}
}
Want results from more Discord servers?
Add your server