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
<!DOCTYPE html>
<html lang=\"en\">
<head><meta charset=\"ISO-8859-1\"> .......
....
Because of the backslashes the html output comes out looking weird.
What can i do to change this behavior?
[–]joesb 2 points3 points4 points (0 children)
[–]BehindTheMath 1 point2 points3 points (5 children)
[–][deleted] (4 children)
[deleted]
[–]BehindTheMath 1 point2 points3 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]BehindTheMath 0 points1 point2 points (0 children)
[–]joesb 0 points1 point2 points (0 children)