mapping string to int
This commit is contained in:
@@ -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();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user