Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nestjs http method delete method send body data arrive empty

Tags:

http

nestjs

I build nestjs project with microservices and I'm trying to send body data from HTTP method "delete" and get the data from req.body. that data is arrive empty.

nestjs project

  await this.httpServiceInstance
    .delete(`deleteData`, {
    data,
    })

microservice project

routes

  app.delete("/deleteData", endpoint(deleteData));

function deleteData

        module.exports = async (req) => { console.log(req.body) /* more code*/ } 

it's print empty object {}

like image 310
Manspof Avatar asked Feb 20 '26 05:02

Manspof


1 Answers

Please set $httpProvider in your config this way:

$httpProvider.defaults.headers.delete = { "Content-Type": "application/json;charset=utf-8" };

and then call delete request:

await this.httpServiceInstance
.delete(`xxxxx`, {
data,
})
like image 97
Michel Gokan Khan Avatar answered Feb 24 '26 13:02

Michel Gokan Khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!