G
G
Galdar Turin2020-09-09 00:37:11
Node.js
Galdar Turin, 2020-09-09 00:37:11

How to process json data in net?

Here comes the data

spoiler
Connect
POST / HTTP/1.1
Content-Type: application/json; charset=utf-8
User-Agent: PostmanRuntime/7.26.3
Accept: */*
Postman-Token: 
Host: 
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 19

{
    "test": 1
}


net.createServer( (sockComm) => {

    sockComm.on('data', ( command ) => {
        console.log(JSON.parse( command.toString() ) )
    })
    
    sockComm.on('end', ( command ) => {
        console.log(command)
    })

}).listen(port_command)

how to extract JSON data from them, or you need to do it differently. I would not want to use the http library or something third-party, but if it makes sense to reconsider the options, I will be glad to read it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question