Somehow I realized that when I pass array of numbers to the backend expressjs I I would get array of strings instead of numbers.
This is the ajax code for sending the data
$.ajax({
method: 'post',
url: this.url.ajax.send,
data,
})
This is the values I have in frontend passing to backend
const data = {
"type": [
1,
2
],
"to": [
0
],
"message": "testing message here"
}
this is what I get in my backend req.body
{ type: [ '1', '2' ],
to: [ '0' ],
message: 'testing message here' }
I do have bodyParser setup like such
app.use(bodyParser.urlencoded({
extended: true,
parameterLimit: 2000000, // too many parameter if not set
limit: 1024 * 1024 * 10 // entity too large if not set
}));
app.use(bodyParser.json({
extended: true,
parameterLimit: 2000000, // too many parameter if not set
limit: 1024 * 1024 * 10 // entity too large if not set
}));
Is this normal or any way I can fix it?
EDIT: This is an image I see from network tab in chrome's inspect tool

const data =is what Iconsole.logthe values right beforeajaxcall though