Supertest converts number query params to string
See original GitHub issueHello, I’m having an issue with supertest when I send a number param by query. The server catches the params as string.
PD: I’ve got a transform in the DTO to convert any string value into a number.
this is my test
it('should retrieve all the template with the params the limit,page', async (done) => {
// Arrange
let params = {
limit: 10,
page: 1
}
// Act
const response = await supertest(app.getHttpServer())
.get("/email/get")
.set('Content-Type', 'application/json;charset=utf-8')
.set("Content-Lenght", '51')
.set('Authorization', 'bearer ' + globalToken)
.query({ limit: params.limit, page: params.page })
});
Any help ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
Supertest converts number query params to string #622
Hello, I'm having an issue with supertest when I send a number param by query. The server catches the params as string.
Read more >how to send number query params in supertest request
I'm trying to test an API endpoint and for that I'm using supertest request, the thing is that the endpint is geting the...
Read more >supertest.Test.query JavaScript and Node.js code examples
Best JavaScript code snippets using supertest.Test.query(Showing top 15 results out of 315) · test/controllers/location/location. · test/controllers/message/ ...
Read more >Developers - Supertest converts number query params to string -
Hello, I'm having an issue with supertest when I send a number param by query. The server catches the params as string. PD:...
Read more >mocha/supertest/nodejs How To Access Request ...
The code below works except that there is a query parameter added. var supertest = require('supertest'); var request = supertest('localhost:3001 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Jumping in here for another opinion, but I thought query params were always parsed as strings and it’s up to you to convert them in your route handlers.
Querystring is a string. Your server code should parse keys in the querystring that should be converted to numbers manually.