Sunday 29 December 2019

html in json response

I want to return the content of an html file inside of a json response.This is what i have at the moment:fs.readFile(output_path, function(err, data) {if (err) {return res.status(400).send({              message: "There seems to be an issue with file type / file"            });    }return res.status(200).send({msg: "bla bla doesnt matter",            data: data.toString("utf8")          }); output path is the path to the html file.When i receive the json i inspect the data variable and the html is in weird format.Meaning that the html tags are wrapped in backslashes: see below ...........Because of the backslashes the html output comes out looking weird.What can i do to change this behavior?

Submitted December 29, 2019 at 03:50PM by jcoder42

No comments:

Post a Comment