Open sherryhhx opened 2 years ago
To clarify this bug, this happens when trying to call .send
with an object, e.g.
await request(app.getHttpServer())
.post('/foo/bar')
.send({a: 1});
The workaround is to call JSON.stringify on the payload, e.g.
await request(app.getHttpServer())
.post('/foo/bar')
.send(JSON.stringify({a: 1}));
Superagent should catch this by tightening TS typing and should have a nicer error message
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object at Function.byteLength (buffer.js:724:11) at Request._end (xxxx/node_modules/superagent/lib/node/index.js:804:84) at Request.end (xxx/node_modules/superagent/lib/node/index.js:777:15)