I have log file named request.log this is the content of the log file
[2022-06-30T09:56:40.146Z] ### POST https://test.csdf/auth/send_otp
{
"method": "POST",
"headers": {
"User-Agent": "testing",
"Content-Type": "application/json"
}
}
[2022-06-30T09:56:40.668Z] ### POST https://test.csdf/auth/login
{
"method": "POST",
"headers": {
"User-Agent": "testing",
"Content-Type": "application/json"
}
}
how can I parse the log file and transform it into array json object like this
[
{
"method": "POST",
"url": "https://test.co/otp"
},
{
"method": "POST",
"url": "https://test.co/login"
}
]
https://test.co/otpnorhttps://test.co/loginare actually anywhere to be found in your sample data. So do you actually want to manipulate those URLs from the log file ... or just pay a little more attention when asking?[, and if so, extract method & URL, if not, skip it and process the next one ...fs.createWriteStream()in there to log the request payload.