First I apologize for the typos, I'm Brazilian
I visited the question below, but it didn't help me solve my problem
ERR_HTTP_HEADERS_SENT: Cannot set headers after they are sent to the client
I have a method that I call from the route localhost:4000/returnvalues
on the first request, it works as expected
but in the next one, it returns the following error
_http_outgoing.js:526
throw new ERR_HTTP_HEADERS_SENT('set'); ^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
my code
module.exports = app => {
const formidable = require('formidable')
const path = require('path')
const folder = path.join("C:/Users/Rafael/Desktop", 'files')
const fs = require('fs')
var form = new formidable.IncomingForm({
uploadDir: folder,
keepExtensions: true
})
const returnvalues = async (req, res) => {
form.parse(req, (_, fields, files) => {
app.api.readFile.readFiles(files.Teste.path).then(values => {
res.status(200).send(values)
})
})
}
return { returnvalues }
}
I tried unsuccessfully to use
return res.status(200).send(values)
this method returns me an object read from an excel spreadsheet