I've tried everything but this just seems impossible to fix. I have browsed every proposed solution on stackoverflow and burned through 3 google pages.
Things I've tried
- Added
extended: true/false
within bodyParser.json - Used bodyParser.urlencoder()
- Switched over and used multer extension following this tutorial but kept getting a
path not found
error.
Someone please help
React handlePrinting function:
async function handlePrinting (file) {
const raw = file.getFileEncodeBase64String()
const destination = 'printer'
const key = file.file.lastModified
var data = {
raw: raw,
pageRanges: pageRanges,
sides: sides,
copies: copies,
destination: destination,
key: key
}
await axios
.post('/api/print/submit', data)
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
Express:
router.use(bodyParser.json({
parameterLimit: 100000,
limit: '50mb'
}))
router.post('/submit', (req, res) => {
const data = {
raw: req.body.raw,
pageRanges: req.body.pageRanges,
sides: req.body.sides,
copies: req.body.copies,
destination: req.body.destination,
key: req.body.key,
}
Print.create(data, (error, post) => {
if (error) {
console.log(`Printing submit error: ${error}`)
return res.sendStatus(BAD_REQUEST)
}
printFunction(data.raw, data.copies, data.sides, data.pageRanges, data.destination)
return res.status(OK).send(post)
})
})