mapping string to int

This commit is contained in:
daniel muniz
2024-06-19 09:55:48 -03:00
parent a5416b6e2c
commit 36ca1a19e3

View File

@@ -15,15 +15,17 @@ server.on('message', async (msg, rinfo) => {
console.log(`Server got: ${msg} from ${rinfo.address}:${rinfo.port}`); console.log(`Server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
const strMsg = msg.toString() const strMsg = msg.toString()
const categories = await app(strMsg) let categories = await app(strMsg)
let result = {} let result = {}
categories = categories.map(category => parseInt(category))
if (categories) if (categories)
result = { result = {
result: categories result: categories
} }
console.log(result)
server.send(JSON.stringify(result), rinfo.port, rinfo.address, (err) => { server.send(JSON.stringify(result), rinfo.port, rinfo.address, (err) => {
if (err) server.close(); if (err) server.close();
}); });