-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DELETE will not accept a body #257
Comments
👋 Hey @kaitpw,
I tried to reproduce but I have no issues on my end. // index.mjs
import wretch from "wretch"
import http from "node:http"
const server = http.createServer()
server.on("request", (request, res) => {
console.log({ method: request.method, url: request.url, headers: request.headers })
request.on("data", chunk => { console.log({ chunk: chunk.toString("utf-8") }) })
request.on("end", () => { res.end("end") })
})
server.listen(8000)
const api = wretch("http://localhost:8000")
.middlewares([
next => async (url, opts) => {
console.log("Wretch Request Details:", {
url,
method: opts.method,
headers: opts.headers,
body: opts.body,
})
return next(url, opts)
},
])
api
.json({ hello: "world" })
.delete()
.text(console.log)
.catch(console.error)
.then(() => server.close()) Running
|
It seems like delete requests accept |
@gruni1992 I'm not so sure about this. 🤔
api
.body("hello world")
.delete()
.text(console.log)
.catch(console.error)
.then(() => server.close())
|
Closing the issue now, but feel free to continue the discussion if you find a way to reproduce. 🙇 |
I was intrigued with wretch so I've tried using it in a project of mine. I'm having issues with
.delete
though which I saw mentioned in other issues. I've tried every way to pass a body to delete (.json(payload).delete()
,.body(JSON.stringify(payload)).delete()
(setting content type too), and `.delete(payload)).delete()
's type also doesn't specify allowing a body:I made a small middleware that also prints the request before sending and it prints the following message everytime
Am I missing something?
The text was updated successfully, but these errors were encountered: