chaijs / chai-http

HTTP Response assertions for the Chai Assertion Library.
http://chaijs.com/plugins/chai-http
633 stars 113 forks source link

How to set request method dynamically? #272

Open amesinp opened 4 years ago

amesinp commented 4 years ago

I am currently achieving this by initializing the request then modifying the method before sending. Something like this:

const request = chai.request(app)
  .get(url)
  .set('Authorization', bearerToken);
request.method = newMethod;

const response = await request.send(data);

I am wondering if there is a better way to go about this.

Thank you

usama8800 commented 3 years ago

Can't we do chai.request(app)[newMethod](url).send(data)?